-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Misleading error when incorrectly initializing a struct using Monster() instead of Monster{...} #6702
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
Comments
I called Monster() instead of Monster{...} - the error which was raised did not help me to find the problem ... I'd have expected sth like "Intialize structs using Monster{...}" or so ... but b/c of that error I looked for hidden utf8 chars :) |
'Monster' could also be a function name, so the compiler can't tell what it should do. Having said that, according to our style guide functions and methods should be lower case, so perhaps the compiler could give a more helpful message in this case. For example by assuming that you meant to initialize a struct when it encounters a function call that starts with a capital letter and is not a function, but does match the name of a struct. |
On incoming I get:
|
@Thiez We can actually do better, since in resolve, the compiler already knows what names correspond to structs when it's printing out an error message. I'm about to submit a pull request to improve the error message. |
The text was updated successfully, but these errors were encountered: