-
Notifications
You must be signed in to change notification settings - Fork 428
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
Fix 2695: local open + let bindings #2716
Conversation
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.
This looks great, thanks!
@@ -6442,7 +6442,12 @@ let printer = object(self:'self) | |||
(atom ("."))) | |||
(self#formatNonSequencyExpression e)) | |||
else | |||
Some (makeLetSequence (self#letList x)) | |||
Some |
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.
this looks exactly like the then
branch.
I'm surprised this doesn't break let open Foo; bar;
for example?
Perhaps the letop
case should be added to isSeriesOfOpensFollowedByNonSequencyExpression
, then we'd get printing for free?
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.
Well, not exactly the same. The first branch results into extra braces:
- let* x = Js.Promise.resolve(42);
- Js.Promise.resolve(x * 2);
+ {
+ let* x = Js.Promise.resolve(42);
+ Js.Promise.resolve(x * 2);
+ }
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 did make a small change to avoid code duplication
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 don't see how this is correct yet. I might be missing something.
Aren't we replacing ALL open
calls with Foo.( ... )
?
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.
Not exactly, but the solution wasn't perfect (it didn't work for nested local open modules). I've tried to improve on it with help of an extra attribute set by the parser.
e7308d4
to
722e1a6
Compare
Thank you again, and sorry for the delay |
CHANGES: - Add `\u{hex-escape}` syntax (@anmonteiro, [reasonml/reason#2738](reasonml/reason#2738)) - Support local open and let bindings (@SanderSpies) [reasonml/reason#2716](reasonml/reason#2716) - outcome printer: change the printing of `@bs.*` to `@mel.*` (@anmonteiro, [reasonml/reason#2755](reasonml/reason#2755)) - Fix outcome printing of optional arguments on OCaml 5.2 (@anmonteiro, [reasonml/reason#2753](reasonml/reason#2753)) - support parsing and printing of `external%extension` (@anmonteiro, [reasonml/reason#2750](reasonml/reason#2750), [reasonml/reason#2766](reasonml/reason#2766), [reasonml/reason#2767](reasonml/reason#2767)) - install `refmt` manpage (@anmonteiro, [reasonml/reason#2760](reasonml/reason#2760)) - add support for parsing / printing of refutation clause in `switch` (@anmonteiro, [reasonml/reason#2765](reasonml/reason#2765)) - support `let%ppx` in signatures (@anmonteiro, [reasonml/reason#2770](reasonml/reason#2770))
CHANGES: - Add `\u{hex-escape}` syntax (@anmonteiro, [reasonml/reason#2738](reasonml/reason#2738)) - Support local open and let bindings (@SanderSpies) [reasonml/reason#2716](reasonml/reason#2716) - outcome printer: change the printing of `@bs.*` to `@mel.*` (@anmonteiro, [reasonml/reason#2755](reasonml/reason#2755)) - Fix outcome printing of optional arguments on OCaml 5.2 (@anmonteiro, [reasonml/reason#2753](reasonml/reason#2753)) - support parsing and printing of `external%extension` (@anmonteiro, [reasonml/reason#2750](reasonml/reason#2750), [reasonml/reason#2766](reasonml/reason#2766), [reasonml/reason#2767](reasonml/reason#2767)) - install `refmt` manpage (@anmonteiro, [reasonml/reason#2760](reasonml/reason#2760)) - add support for parsing / printing of refutation clause in `switch` (@anmonteiro, [reasonml/reason#2765](reasonml/reason#2765)) - support `let%ppx` in signatures (@anmonteiro, [reasonml/reason#2770](reasonml/reason#2770))
Solves #2695.
Makes it possible to use:
Printing isn't perfect, but good enough for now.