[Issue 11720] Function-local static variables should cause "already defined in another scope" error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 10 20:29:13 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11720



--- Comment #4 from Kenji Hara <k.hara.pg at gmail.com> 2013-12-10 20:29:10 PST ---
(In reply to comment #3)
> (In reply to comment #2)
> > https://github.com/D-Programming-Language/dmd/pull/2947
> 
> Is having it error really the right way to fix this? It looks to me to be an
> issue with the fact that the bodies of a statically expanded foreach are not
> specially mangled.

Yes. In D, function local declarations which are assigned to global symbols
cannot have same name because of the mangled name conflict.

void main()
{
  { void f() {} }
  { void f() {} }  // Error: declaration f is already defined in another scope
in main

  { struct S {} }
  { struct S {} }  // Error: declaration S is already defined in another scope
in main

  { static int v = 1; }
  { static int v = 1; }  // should be same error
}

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


More information about the Digitalmars-d-bugs mailing list