fails: void foo() { bar(); void bar() { } } passes: void foo() { void bar() { } bar(); } I realize this may not be a simple solution in all cases but surely it can be make to work in such simple cases?