Forbid privacy in inner functions

Closes #10111