-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
compiler error message can improve: when forgetting = after proc signature #10229
Comments
Btw, nim is so cool! really enjoying it, and the power to extend types transparently. |
The error message is pretty clear IMO.
This means that what you have written is a forward declaration and does not contain its implementation. Which means that you did this intentionally and are going to write the implementation later in this file. Or it could mean that you missed the
This means that the indentation is wrong, because you miss the
This means that because you never implemented the proc, those identifiers are never declared.
pairs takes one argument but the argument
(IDK what is result doing in global scope and why it is immutable but) this means that you passed wrong arguments to the So I don't see what should/could be done here if people don't bother to learn the language. |
its a common error, and its easy to improve err msg generated by compiler here. We can just show just 1 relevant error (eg:
) instead of cascade of errors as shown above. |
@timotheecour The current error message is 100% correct for all cases. Also the node in the Ast for the above case stores just the proc as a forward decl, and the next line is another node. There is no easy way AFAIK to produce 100% correct messages for all cases if your suggestion is followed. Adding extra complexity to the code for fixing something which is already correct is a wasted effort IMO. So this should be a |
I added here's some more info that shd be mentioned. I'm using latest devel 0229dfd I have no idea what
(ignore the full path; what matters is fact error is
|
The compiler by default stops at the first error message. The first error encountered is of course the invalid indentation. Because the previous line (the proc (And your second output is the same as in the OP) |
no, the one in OP shows I still think we can improve a bit by simply saying in this case (for 1st msg):
changed to:
that's a 1 line patch in compiler, and is a small but user friendly improvement. (a more refined patch would autodetect whether we're following a declaration, but may be un-necessary) [EDIT] a separate issue is that sometimes errors produced via |
The part So IMO this is not an improvement. But lets wait for what @Araq has to say. |
Hello again,
I think, for a newcomer, it's important to have clear messages of what to change, and how --from the language perspective, less important is the why (internals) from the compiler's perspective. Most languages that I know don't need the "=" sign after the signature, so this is bound to be a common mistake for newcomers. PS: for inspiration and examples, the best error reporting I saw was in the cobra language. it was always clear what to do, and sometimes even explained how to fix the code. from that perspective it was a joy to work with. it sounds like a small thing, but actually prevents a lot of head scratching, and doesn't interrupt your train of thought. |
Well I am not going to argue anymore. If someone wants to implement this, go ahead. But I still stand by my points, which I am rewriting here for those who don't want to read through all the above posts.
Anyways I won't be discussing this topic anymore. |
@nc-x syntax errors are always a bit harder to explain: it is obvious to you as an experienced nim guy what might be the error, but this is because you learned to deal with it, not because it's a good error message. Actually this kind of error message makes the user guess the error instead of saying exactly what might be the possible reasons. Showing possible reasons is not going to turn off people: it's helpful, and help is the only reason error messages exist at all instead of just returning 1. The change might be technically hard, if this is so, I guess it's ok to not implement it, but it doesn't mean the error message is perfect. |
Well |
One year passed, nothing changed. |
special case of the more general #10229 |
You know, for beginners.
example code:
without
=
I get (in vscode):The text was updated successfully, but these errors were encountered: