Sample code: int foo(int x) { switch(x) { case 0: goto Bar; Bar: default: auto y = 6; return y; } } void main() { auto x = foo(0); } What I get: Error: undefined identifier `y` What I expect: The compiler to remember the variable was declared the line immediately above and use that.
Of course the workaround is just to swap the label and the default case.
@ibuclaw created dlang/dmd pull request #14747 "fix Issue 23586 - DMD forgets a variable was just declared" fixing this issue: - fix Issue 23586 - DMD forgets a variable was just declared https://github.com/dlang/dmd/pull/14747
dlang/dmd pull request #14747 "fix Issue 23586 - DMD forgets a variable was just declared" was merged into master: - e842284b8e0855d8bda6006e2758a1bfa56c69af by Iain Buclaw: fix Issue 23586 - DMD forgets a variable was just declared https://github.com/dlang/dmd/pull/14747