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 17518 - [Reg 2.063] confusing error message with inout constructor/ctor #9102

Merged
merged 1 commit into from
Dec 21, 2018

Conversation

RazvanN7
Copy link
Contributor

struct S
{
    this(inout Correct) inout
    {
    }
}

struct Correct {}
struct Wrong {}

S bug()
{
    return S(Wrong());
}

Yields: Error: inout method bug.S.this is not callable using a mutable object, because the modifier is checked first althoug the error comes from the fact the type is different. The fix is to see if any supplemental errors exists (which is used only for parameter types); if that is the case, then print the new more relevant error, otherwise print the former error.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
17518 regression [Reg 2.063] confusing error message with inout constructor/ctor

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

To target stable perform these two steps:

  1. Rebase your branch to upstream/stable:
git rebase --onto upstream/stable upstream/master
  1. Change the base branch of your PR to stable

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + dmd#9102"

@Geod24
Copy link
Member

Geod24 commented Dec 20, 2018

Why aren't overloaded functions covered ?

@RazvanN7
Copy link
Contributor Author

@Geod24 Because when there are multiple overloads and none of them are matching, there is no specific overload to pinpoint the exact mistake.

@dlang-bot dlang-bot merged commit 624236c into dlang:master Dec 21, 2018
@Geod24
Copy link
Member

Geod24 commented Dec 21, 2018

@RazvanN7 :

struct S
{
    this(inout Correct) inout
    {
    }
    this(int) {} // New addition
}

struct Correct {}
struct Wrong {}

S bug()
{
    return S(Wrong());
}

Results in:

msg.d(14): Error: none of the overloads of __ctor are callable using a mutable object, candidates are:
msg.d(3):        msg.S.this(inout(Correct) _param_0)
msg.d(6):        msg.S.this(int _param_0)

Which is obviously wrong. Using an error message similar to the one you put there ("is not callable using argument type...") makes more sense.

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

Successfully merging this pull request may close these issues.

5 participants