April 14, 2014 [Issue 12578] New: Allow local function overloading | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=12578 Issue ID: 12578 Summary: Allow local function overloading Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: DMD Assignee: nobody@puremagic.com Reporter: monarchdodra@gmail.com >From the conversation: http://forum.dlang.org/thread/gxzqflbxjmlewdsfwykt@forum.dlang.org Basically, this fails: //---- void main() { void foo(); void foo(int); } //---- Error: declaration foo is already defined //---- I *think* this is according to spec? However, I find this behavior unrational, since you can get it to work with a simple wrap: //---- void main() { static struct S { static void foo(); static void foo(int); } alias foo = S.foo; } //---- Fine! No problem! //---- Given that the second example compiles, I think the D language should allow local function overloading. ... Or, if the issue is one of scope/context/forwardreferences (?) to at least allow overloading of static local functions, eg: //---- void main() { static void foo(); static void foo(int); } //---- -- |
Copyright © 1999-2021 by the D Language Foundation