Fix issue 6400 - Better interaction between with() and opDispatch#6439
Fix issue 6400 - Better interaction between with() and opDispatch#6439WalterBright merged 1 commit intodlang:masterfrom LemonBoy:b6400
Conversation
|
src/expression.d
Outdated
| ss = sc2.scopesym.isWithScopeSymbol(); | ||
| } | ||
|
|
||
| if (ss && ss.withstate.wthis) |
There was a problem hiding this comment.
This logic could be simplified by moving it inside the loop above.
|
@WalterBright What about nested with (foo)
{
with (bar)
{
baz();
}
} |
|
I'd say the innermost scope wins. |
|
Looks good. Please add a test case with the nested |
|
I've touched up the test-case a bit, I hope it's not too convoluted. |
| } | ||
| with (baz) | ||
| { | ||
| static assert(!__traits(compiles, f2())); |
There was a problem hiding this comment.
I would have expected calling f2 to print foo here.
There was a problem hiding this comment.
@andralex @WalterBright what's your take on this? It's very unusual that outer symbols are not visible in inner scopes (even if the symbol is rewritten to opDispatch).
There was a problem hiding this comment.
Yes, looks like one more step closer to C++'s "nobody knows what this language construct will actually do".
No description provided.