Simplify error messages reported by the compiler #853
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "ghallak/354"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes: #354
This PR changes most error messages to:
aeso_errors:pp
but not in#err.msg
).at line x, col y
) when it's already available from#err.pos
.x
", instead of "Unbound variable x").Created by: dincho
IMO the compiler lib should not do any formatting at all but provide a list of structured errors downstream, that is to the HTTP and CLI compilers.
As an example structure I've in mind would be: type, line, column, message. hint
Created by: dincho
As an example of very hard to parse error message is:
A lot of newlines.
Another example duplicating position information and non-sense newlines:
Created by: hanssv
@dincho I think this is a good compromise, you can get a raw(ish) form of the error from the compilier, and you can ask the compiler to format it further. Or you can get the information in JSON. The reason for keeping it all in
aesophia
is to make updates/additions less cumbersome - otherwise you'd have to remember there is a new error when updating aesophia_cli/http, etc.I don't see any major issues with the provided examples (they should no longer have duplicated position information!?) - separating different errors with a newline makes sense I think?
Created by: hanssv
Review: Approved
@dincho Could you go over the changes to the files
test/aeso_compiler_tests.erl
andsrc/aeso_ast_infer_types.erl
, to see if there are any error (or warning) messages that you think could be changed to be better?Created by: dincho
that's for sure, but I still see multiple newlines in a "single" error messages in the tests cc @ghallak
that's my main issue, for a practical example I'm building a sublime plugin that parses the CLI output, however using \n for error messages separator (which is fine, and is used in all the compilers I'm aware of), the usage of \n in the error message itself makes it un-parsable.
I've seen related issues for other languages reported elsewhere, and it seems to be e common (seen) practice in functional language compilers to use newlines in the error messages itself. Still, it does not makes much sense to me.
Created by: hanssv
The primary purpose of the errors output by
aesophia_cli
is to be read by a human rather than parsed by a tool! Perhaps we could add a switch (--raw_errors
or something similar) toaesophia_cli
?And no, putting
\n
into a string doesn't make it unparseable but that discussion we've had before 😅Created by: dincho
Humans are lazy and use tools .. 😅
Created by: dincho
Well, define that in regex, then we talk again :)
Created by: hanssv
Well...
parsing != regex
😈Normally you use
/s
or?s
as modifier to do multiline regex?Created by: hanssv
Let's merge this, and I'll tackle @dincho's issue in a follow up PR (and
aesophia_cli
).Merged by: hanssv at 2022-01-05 10:22:22 UTC