[Issue 12578] New: Allow local function overloading
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 14 03:56:01 PDT 2014
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 at puremagic.com
Reporter: monarchdodra at 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);
}
//----
--
More information about the Digitalmars-d-bugs
mailing list