-
Notifications
You must be signed in to change notification settings - Fork 11
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 #10
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: type invalid = { i : int; create : int; fold : int } [@@deriving fields]
let _ = i which, when raising instead of embedding errors, would not list both errors (both |
Hello @panglesd, please I can I work on this issue. |
Hello @panglesd, please I am facing some difficulties, I used the steps you listed in the other issue on metaquot, here is the code I added
to replace
but I get this error
it seems like an else branch is missing but i dont know the condition to apply if i am to include one, or how to work around this error without including an else branch. I will do a draft pull request containing the most recent changes |
Currently, when
ppx_fields_conv
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_fields_conv
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:
Unsupported use of fields (you can only use it on records
forinvalid1
: the right errorThe error for
invalid2
is not shown, since the rewriting is cancelled when the exception is raised.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: