www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4894] New: Cannot use the same name for nested functions even though they're in different scopes

http://d.puremagic.com/issues/show_bug.cgi?id=4894

           Summary: Cannot use the same name for nested functions even
                    though they're in different scopes
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jmdavisProg gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisProg gmx.com> 2010-09-19 01:11:25
PDT ---
This fails to compile

void main()
{
    {
        int nestedFunc(int val)
        {
            return val;
        }
    }
    {
        float nestedFunc(float val)
        {
            return val;
        }
    }
}


with the error

d.d(10): Error: declaration nestedFunc is already defined in another scope in
main


The functions are in separate scopes. No name shadowing is occurring. I don't
see why they can't both exist. If they were variables, there would be no
problem. Obviously, this is intentional given the specificity of the error
message, but it seems overly restrictive to me. So, I'm submitting it as a
feature request that nested functions be allowed to have the same name if
they're in separate scopes and no name shadowing/hiding can occur.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 19 2010