-
Notifications
You must be signed in to change notification settings - Fork 463
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
POC: print patterns in warnings using rescript printer #5492
Conversation
How does ocaml do it? Does it have its own |
There's an untype mapper for pattern in untypeast which is much like the one in PR but with different label names. |
does paranthesis have meaning in |
The fact that we need to ask the question (and I'd need to go and check to remind myself eg what about type annotations) means the printer knows better and it's not the compiler's error message business. |
I think this PR is good to go, as long as one resolves what's going on in CI. |
Thanks. |
I've added another prepass before printing in order to avoid extra nested parens when printing |
This branch needs this patch rescript-lang/syntax#595 for compiling |
This looks good.
Then we can merge. |
will revisit this soon |
0014839
to
d97fd17
Compare
rebased on master |
You forgot to handle a possible case here, though we don't have more information on the value. |
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.
@amiralies did something go wrong rebasing on master, or what's going on with these tests?
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 didn't update test results
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 ran the tests and what you see is the current output.
759f586
to
8c280d2
Compare
Can you do a |
% git diff
diff --git a/jscomp/core/bs_conditional_initial.ml b/jscomp/core/bs_conditional_initial.ml
index 79fdf1e97..7a85592e0 100644
--- a/jscomp/core/bs_conditional_initial.ml
+++ b/jscomp/core/bs_conditional_initial.ml
@@ -34,7 +34,6 @@ let setup_env () =
Ctype.variant_is_subtype := Matching_polyfill.variant_is_subtype;
Clflags.dump_location := false;
Config.syntax_kind := `rescript;
- Parmatch.print_res_pat := Pattern_printer.print_pattern;
# 38 "core/bs_conditional_initial.pp.ml"
Clflags.color := Some Always;
@@ -74,4 +73,4 @@ let setup_env () =
let () =
- at_exit (fun _ -> Format.pp_print_flush Format.err_formatter ())
+ at_exit (fun _ -> Format.pp_print_flush Format.err_formatter ()) |
let me see what's happening |
Oh right need to change this instead: |
This now behaves as expected. |
Just one final cleanup. |
@amiralies see the final cleanup I think this is ready to merge. OK? |
Yes! it looks better now |
needs exposing printPattern function from res_printer.
there's also an issue with or patterns printing redundant parens which i don't know should be fixed in printer or compiler