Skip to content
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

[Super errors] Specialize error msgs for Reason syntax when needed #2616

Merged
merged 1 commit into from Mar 15, 2018

Conversation

chenglou
Copy link
Member

See the updated error/warning msgs

@chenglou
Copy link
Member Author

chenglou commented Mar 13, 2018

Before:
screenshot 2018-03-12 22 40 40
After:
screenshot 2018-03-12 22 40 02

Same messages tweaks for the OCaml syntax. That floating dot is the actual .. Just prettified by my font.

cc @sgrove @bsansouci

Arg.Unit Reason_outcome_printer_main.setup,
Arg.Unit (fun () ->
Reason_outcome_printer_main.setup ();
Super_reason_flag.using_reason_syntax := true
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 is this the right way to do it?

_
)
->
if !Super_reason_flag.using_reason_syntax then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this module only print reason syntax, lets keep things simple, make improved error message only work for reason syntax ?
Currently, we did not activate better error message for ocaml syntax. In that case we don't need add a new state variable here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason syntax printer is in a different module. This module’s logic is shared with typecore. Also, I’m pretty positive lots of pure ocaml projects enable super errors manually. Bsb is also in vscode and atom plugins’ configurations now, so we can’t skim on these features imo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do it in a separate PR so that we can merge this strictly better PR quickly -- I think we already had something relevant to whether reason syntax is enabled, but not sure where

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I split the PR? Also, the only thing I've seen that knows whether it's a reason file is Reason_outcome_printer_main.setup(). I can't put the flag there because of cyclic dependencies.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean just always print it in reason syntax (not introducing a ref variable), does it work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't, because pure ocaml bs projects are using super-errors right now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason setup logic is already pretty complex (to be honest, I don't 100% understand how they interact).

My impression is that super-errors is currently only activated for reason syntax, let's not over-promise, having a cursory look at super_typecore module, print_arguments is reason specific, I am not really sure this module is not reason syntax specific.

I think we should not make the setup logic more and more complex to deliver things we did not promise

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not over-promising, we're just not breaking existing experience. That print_arguments has one reason syntax-specific line because I missed it, but it's easy to make it work with ocaml syntax too.

Take a look at this result: https://github.com/search?q=-bs-super-errors&type=Code&utf8=✓
Some prominent projects, including the graphql integration (pure ocaml), uses super-errors.

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 don't think we're over-promising here. We've never really had reason-specific logic in super-errors (printing the outcome tree in reason is independent of super-errors. It's used elsewhere too), except that print_arguments which is my fault

See the updated error/warning msgs

As per feedback, we're gonna do it for Reason syntax for now. We'll add
back the support for OCaml syntax later.
@chenglou
Copy link
Member Author

As per feedback, we're gonna do it for Reason syntax for now. We'll add
back the support for OCaml syntax later.

@chenglou
Copy link
Member Author

Alright, since this is now just two messages tweaks, I'll merge it. I'll submit the reason flag as a different PR

@chenglou chenglou merged commit c9e5bf2 into rescript-lang:master Mar 15, 2018
@chenglou chenglou deleted the super branch March 15, 2018 09:34
chenglou added a commit to chenglou/rescript-compiler that referenced this pull request Mar 15, 2018
chenglou added a commit to chenglou/rescript-compiler that referenced this pull request Mar 19, 2018
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.

None yet

2 participants