-
Notifications
You must be signed in to change notification settings - Fork 28
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
Embed errors in the AST instead of raising #45
Comments
Note that we decided that we will change the ppxlib behaviour regarding the handling of exceptions, to match the current use of However, embedding errors can still have advantages: It allows reporting multiple errors, while still outputting valid AST for the part that were successful. In the case of this PPX, the example could be rewritten as: let%expect_test "invalid" =
Printf.printf "%d" (1 + 2);
[%expect {| multi
line without empty line |}];
Printf.printf "%d" (1 + 2);
[%expect {| multi
line without empty line |}] which, when raising instead of embedding errors, would only report a single error, instead of all. |
@panglesd I would like to work on this issue for Outreachy. Can it be assigned to me. Thank you! |
Let it be assigned to you! |
@panglesd I'm not able to spot the |
I suggest you start with fixing the example given in #45 (comment), which instead of reporting three errors, would only report one: the one mentioned in the first post: |
@panglesd I have made the following changes in
However, when I run |
Currently, when
ppx_expect
encounters an error, it uses theraise_errorf
function to raise a located error.The exception is caught by
ppxlib
, which in this case:[%%%ocaml.error ...]
extension node) to the last valid astThe interruption of the rewriting is quite bad for the user experience! The implication for the users are:
ppx_expect
runs at the "context-free" phase, the "last valid AST" is before the context-free phase. So, no other derivers/extenders get run, which generates a lot of noise in the errors (such as "uninterpreted extensions" or "unbound identifiers")Example
For instance:
would report several errors:
Multi-line expectations must start with an empty line
forinvalid1
: the right errorUninterpreted extension 'expect_test'
forinvalid1
,invalid2
andvalid
The "uninterpreted extensions" errors are noise, and the "multi-line expectations [...]" error is not shown for
invalid2
.You can find more information about error reporting in PPXs in this section of the ppxlib manual.
❓ Would you be willing to accept contributions to this issue? I'm considering assigning its resolution as part of an outreachy internship: see more information here.
The text was updated successfully, but these errors were encountered: