ppxlib icon indicating copy to clipboard operation
ppxlib copied to clipboard

Improving handling of exceptions in context-free rewriters

Open panglesd opened this issue 4 years ago • 0 comments

A rewriter has several ways to report errors to the user. The best is to embed an error extension point in the generated AST, but the PPX can also either raise a located error exception, or any exception.

Currently, the ppxlib driver catches any exception raised by a rewriter, and:

  • if the exception is a located error and
    • either it is used as a ppx,
    • or it is used as a standalone with the -embed-errors argument,

then it replaces the whole AST by a single located error extension node with a message,

  • In any other case an exception is raised again.

Replacing the whole AST is not satisfying as it prevents any other error to be shown, even in the case of located errors. Only the node that generated the exception should be replaced by an error extension node.

Moreover, what do you think about turning any exception raised by a context-free rewriter into located error (?)

panglesd avatar Oct 11 '21 14:10 panglesd