-
Notifications
You must be signed in to change notification settings - Fork 38
Expose printPattern #595
Expose printPattern #595
Conversation
The analysis will complain a little until this is used. |
I will put this on hold until we decided if want to merge rescript-lang/rescript#5492 .
|
Let's go ahead with this. |
just pushed a commit. |
CI is green so the annotation was fine. opam install reanalyze should take care of your issue |
I got reanalyze installed.
seems like a compiler version mismatch or something? |
Reanalyze can't work for ReScript and ocaml at the same time. |
If you build from source there are 2 build commands for the 2 targets From opam it's always the ml target npm is always the ReScript (ie 4.06) target |
I don't know what was the exact cause but maybe I messed up my switch when upgrading compiler version or I left some old files compiled with different vesrion of compiler when switching between branchs. I think best way to fix similar issues is to do a complete git clean and re-initate switch. |
Was considering whether to make reanalyze resilient to wrong format, but I'm afraid that would only mask issues. |
Is this ready to merge? |
This change by itself is ok but I think we can't use it for partial match warnings due this #595 (comment) |
I did not notice all the parens in that example. |
if the input code contains parens in rhs or patterns it prints like that |
Is it possible to generate the other way round so the printer is OK? |
The printer seems to be fine (I couldn't produce adding unexpected parens) but the question is does it actually matter to preserve parens in I think it can be fixed in compiler too. compiler should generate patterns like
instead of
|
I guess parens doesn't matter to type checker but may affect code generator? |
Changing the printer is definitely the less invasive option. Sounds like the way to go. |
We can ask @IwanKaramazow if it's fine to change printer behavior or not |
We have to be careful that if we change the printer, the output still parses correctly. I vaguely recall there being a difference in left vs right recursion |
There are some comments in reason's parser about this too |
Would you add a link to those comments. |
here it is https://github.com/reasonml/reason/blob/master/src/reason-parser/reason_pprint_ast.ml#L3156 |
It might be just about technical properties. On the other side one of the two could be considered invalid. This means parsing must always bias one way even if parens say otherwise. In other works parsing would also need to do the same work as the printer. This technically would make round trip tests go through. There would be ocaml asts not representable in ReScript. But that's is already true today. None of this is a suggestion on how to proceed. Just stating the implications. |
We can also just implement a printer for this case, seems like not a lot of code at all: https://github.com/rescript-lang/ocaml/blob/1559b1d73e5fb725cabd4f90dd9a076172833558/typing/parmatch.ml#L386-L489 |
No description provided.