You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when ppx_inline_test encounters an error, it uses the raise_errorf function to raise a located error.
The exception is caught by ppxlib, which in this case:
Catch the error,
stops the rewriting process
add the error (as a [%%%ocaml.error ...] extension node) to the last valid ast
Use the resulting AST
The interruption of the rewriting is quite bad for the user experience! The implication for the users are:
Since ppx_inline_test 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")
Only one (meaningful) error from your PPX is reported at a time.
invalid is not a valid tag for inline tests for invalid1: the right error
uninterpreted extension test for invalid2: the wrong error, it should be as for invalid1
uninterpreted extension test for valid: an error when there should not be one
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:
Note that we decided that we will change the ppxlib behaviour regarding the handling of exceptions, to match the current use of raise_errorf in PPXs.
Catching an exception will no longer stop the rewriting process. So, the example I gave in the original issue is not relevant any more.
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:
Currently, when
ppx_inline_test
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_inline_test
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:
invalid is not a valid tag for inline tests
forinvalid1
: the right erroruninterpreted extension test
forinvalid2
: the wrong error, it should be as forinvalid1
uninterpreted extension test
forvalid
: an error when there should not be oneYou 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: