Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 25, 2013

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Dec 11, 2013

@yebblies
Copy link
Member

This is not the correct fix. Each static variable should be given a unique name. ie https://d.puremagic.com/issues/show_bug.cgi?id=3031

@9rnsr
Copy link
Contributor Author

9rnsr commented Dec 11, 2013

I know the issue, but I think rejecting currently unsupported code is better than silently generating wrong code.

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
}

@WalterBright
Copy link
Member

I agree with @9rnsr in that silently generating bad code is always wrong. We may in the future decide to make this work, but until then it's better to generate an error.

WalterBright added a commit that referenced this pull request Dec 25, 2013
Issue 11720 - Function-local static variables should cause "already defined in another scope" error
@WalterBright WalterBright merged commit 5901e16 into dlang:master Dec 25, 2013
@9rnsr 9rnsr deleted the fix11720 branch December 31, 2013 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants