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 16095 - a delegate can mutate immutable data and break shar… #6091

Merged
merged 1 commit into from Aug 27, 2016

Conversation

WalterBright
Copy link
Member

…ed / non-shared enforcements

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
16095 a delegate can mutate immutable data and break shared / non-shared enforcements

@dlang-bot
Copy link
Contributor

@WalterBright, thanks for your PR! By analyzing the annotation information on this pull request, we identified @yebblies, @9rnsr and @MartinNowak to be potential reviewers. @yebblies: The PR was automatically assigned to you, please reassign it if you were identified mistakenly.

(The DLang Bot is under development. If you experience any issues, please open an issue at its repo.)

MODMatchToBuffer(&thisBuf, e1.type.mod, tf.mod);
MODMatchToBuffer(&funcBuf, tf.mod, e1.type.mod);
error("%smethod %s is not callable using a %s%s",
funcBuf.peekString(), f.toPrettyChars(), thisBuf.peekString(), e1.toChars());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be e1.type.toChars(), the diagnostic is currently saying you can't call a method with a non-shared a, but a is just a variable, it should specify the type instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

But non-shared is what I need to know about the type, and I need to know it is a that's the problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm you may be right. I was under the wrong impression that we used to print the type name, but existing diagnostics are:

class C
{
    void ping() { }
}

void main()
{
    auto c = new const C;
    c.ping();
}
Error: mutable method test.C.ping is not callable using a const object

I suppose your approach works fine. :)

@AndrejMitrovic
Copy link
Contributor

Auto-merge toggled on

@AndrejMitrovic AndrejMitrovic merged commit d4f45f9 into dlang:master Aug 27, 2016
@WalterBright WalterBright deleted the fix16095 branch August 27, 2016 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants