https://issues.dlang.org/show_bug.cgi?id=12578
--- Comment #5 from Kenji Hara <[email protected]> --- (In reply to Walter Bright from comment #3) > 2. Forward references aren't allowed in local scope, meaning any use of > overloading would be fairly restricted anyway. By adding following rule for function local declarations, we can relax the restriction. - If no runtime statements exist between two local declarations, compiler will declare them in one DeclDef scope. Examples: ---- void main() { //{ void foo() void foo(int) {} // These are declared in one DeclDef scope, so they can be overloaded each other. //} } The rule will work on general case. void main() { struct S { int foo() { bar(); } static assert(x == 10); } void bar() { S s; } enum x = 10; // Declaraing S, bar, and x have no runtime side effect, // so they can be referred to each other. } If same name function declarations are divided to multiple DeclDefs, they cannot be overloaded. void main() { void foo() void foo(int) {} // foo == overloaded function // --> ok int x; // runtime statement divides DeclDefs void foo(string) {} // Another declaration of foo will conflict with the overloaded foo. // --> error } --
