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 18460 - Improve error message for missing 'new' for class instantiation #7929

Merged
merged 1 commit into from Feb 21, 2018

Conversation

wilzbach
Copy link
Member

One small step on the long road to better diagnostics.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @wilzbach!

Bugzilla references

Auto-close Bugzilla Severity Description
18460 enhancement Improve error message for missing 'new' for class instantiation

error(loc, "no property `%s` for type `%s`", ident.toChars(), toChars());
{
if (ident == Id.call && ty == Tclass)
error(loc, "no property `%s` for type `%s`, did you mean `new %s`?", ident.toChars(), toChars(), toPrettyChars());
Copy link
Member Author

Choose a reason for hiding this comment

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

BTW any reason why toChars is always fully qualified for classes, but not for structs?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know. I suppose that should also be addressed (in another PR).

@dlang-bot dlang-bot merged commit 9db7831 into dlang:master Feb 21, 2018
/*
TEST_OUTPUT:
---
fail_compilation/diag18460.d(12): Error: no property `opCall` for type `diag18460.Foo`, did you mean `new Foo`?
Copy link
Member

Choose a reason for hiding this comment

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

Error: no `static` property `opCall` for...

@wilzbach wilzbach deleted the fix-18460 branch March 13, 2018 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants