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

Fix issue 6400 - Better interaction between with() and opDispatch #6439

Merged
merged 1 commit into from Jan 15, 2017
Merged

Fix issue 6400 - Better interaction between with() and opDispatch #6439

merged 1 commit into from Jan 15, 2017

Conversation

LemonBoy
Copy link
Contributor

No description provided.

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
6400 opDispatch with WithStatement

ss = sc2.scopesym.isWithScopeSymbol();
}

if (ss && ss.withstate.wthis)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic could be simplified by moving it inside the loop above.

@LemonBoy
Copy link
Contributor Author

@WalterBright What about nested with() scopes? In the following example should we warn the user if both foo and bar implement opDispatch? Should we traverse all the scopes until we find a wthis that implements opDispatch?

with (foo)
{
    with (bar)
    {
        baz();
    }
}

@WalterBright
Copy link
Member

I'd say the innermost scope wins.

@WalterBright
Copy link
Member

Looks good. Please add a test case with the nested with case, and I'll pull it.

@LemonBoy
Copy link
Contributor Author

I've touched up the test-case a bit, I hope it's not too convoluted.

@WalterBright WalterBright merged commit c49fb86 into dlang:master Jan 15, 2017
}
with (baz)
{
static assert(!__traits(compiles, f2()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected calling f2 to print foo here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, looks like one more step closer to C++'s "nobody knows what this language construct will actually do".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants