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 199 - Label causes scope to collapse into parent #3024
Conversation
The issue "seems" that it is now always creating a scope after a label. The failure can be reduced to: void main()
{
Lcontinue: size_t curallocsize = void;
curallocsize = 1; //Error: undefined identifier curallocsize
} Maybe this will spontaneously fix after if you solve 10199 first? In any case, I can't wait for this to get fixed. It's been one of my oldest standing issues with the language :) |
Forgot to push after I fixed it! |
This is failing on test 4448, but I think the test is wrong: int bug4448()
{
int n=2;
L1:{ switch(n)
{
case 5:
return 7;
default:
n = 5;
break L1;
}
int w = 7;
}
return 3;
}
This fix also fixes that. The test should be moved to |
I agree. |
@@ -2738,7 +2738,8 @@ static assert({ E8365[2][2][2] x; return x[0][0][0]; }() == E8365.first); | |||
int bug4448() | |||
{ | |||
int n=2; | |||
L1:{ switch(n) | |||
{ switch(n) | |||
L1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised this compiles. What does it do? It's a switch that contains a labeled body? Does the grammar allow this?
It's the switch that should be labeled:
int n=2;
{
L1: switch(n)
{
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't compile. I've wrapped it in a do-while, the test case seemed to intentionally not label the switch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although, it is legal for a switch to have a LabelStatement as its body.
Need corresponding doc pull. |
How do I document this? The old behavior was undocumented... "A label on a statement doesn't do anything weird to the scope" ??? |
@WalterBright ping |
Issue 199 - Label causes scope to collapse into parent
Thanks! |
Do what C does - introduce a scope.
https://d.puremagic.com/issues/show_bug.cgi?id=199