-
Notifications
You must be signed in to change notification settings - Fork 465
Report error in Reason syntax when the error happens in a Reason file #1870
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
Conversation
@@ -159,7 +159,11 @@ let setup () = | |||
Location.register_error_of_exn | |||
(function | |||
| Typetexp.Error (loc, env, err) -> | |||
Some (Location.error_of_printer loc (report_error env) err) | |||
Some (Location.error_of_printer loc (fun ppf -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bobzhang so, I need to detect whether a file's in Reason before printing the error in Reason syntax. But I can't find a higher-level common point to do this instead of duplicating the outcome printer initialization logic everywhere. Putting it in Super_location.super_error_reporter
was too late in terms of printing, apparently.
Some other files like typedecl.ml
would also need to be wrapped this way. If this is a good way to go then I can add them (or lazily add them in a later diff when I do need to change typedecl)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you elaborate a little bit, I did not follow you. You know the input is reason file or not very early? (btw, we can add a flag like -bs-reason-error etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried setting the printer in Super_location.super_error_reporter
but that's not early enough. The earlier one (with access to file name) would be inside each reporter's Location.register_error_of_exn
, as shown here.
Maybe I'm missing something? If not, then -bs-reason-error could be the way to go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you mean
bsc -bs-super-error -c xx.re
will not work but bsc -c xx.re -bs-super-error
will be good?
@bobzhang ok, as discussed offline, I've opted to enable Reason syntax printing without file detection. OCaml files will also print errors in Reason syntax but I think for our target audience this is fine and simple enough. I've looked into CLI flags; I think in the future we could pass a |
@@ -0,0 +1,14 @@ | |||
(* This will be called in super_main. This is how you'd override the default error printer from the compiler & register new error_of_exn handlers *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping it here. Will be used by @cristianoc
CI failed but for arbitrary reason. Restarted it |
Port of rescript-lang#1870, with only the changes relevant to the outcome printer pars.
Port of rescript-lang#1870, with only the changes relevant to the outcome printer pars.
* Report error in Reason syntax (take 2) Port of #1870, with only the changes relevant to the outcome printer pars. * Simplify setup
Superseded by #1880 |
No description provided.