Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

chenglou
Copy link
Member

No description provided.

@chenglou chenglou changed the title test outcome printer test outcome printer (WIP) Aug 10, 2017
@chenglou chenglou changed the title test outcome printer (WIP) Report error in Reason syntax when the error happens in a Reason file Aug 10, 2017
@@ -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 ->
Copy link
Member Author

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)

Copy link
Member

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)

Copy link
Member Author

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?

Copy link
Member

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?

@chenglou
Copy link
Member Author

@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 -bs-print-errors-in-reason flag to the reason ninja rules. Then I could move the outcome printing overriding into that CLI arg's callback.

@@ -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 *)
Copy link
Member Author

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

@chenglou
Copy link
Member Author

CI failed but for arbitrary reason. Restarted it

chenglou added a commit to chenglou/rescript-compiler that referenced this pull request Aug 15, 2017
Port of rescript-lang#1870, with only the changes relevant to the outcome printer
pars.
chenglou added a commit to chenglou/rescript-compiler that referenced this pull request Aug 15, 2017
Port of rescript-lang#1870, with only the changes relevant to the outcome printer
pars.
chenglou added a commit that referenced this pull request Aug 15, 2017
* Report error in Reason syntax (take 2)

Port of #1870, with only the changes relevant to the outcome printer
pars.

* Simplify setup
@chenglou
Copy link
Member Author

Superseded by #1880

@chenglou chenglou closed this Aug 15, 2017
@chenglou chenglou deleted the outcome branch August 15, 2017 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants