-
Notifications
You must be signed in to change notification settings - Fork 38
Some((a, b)) formats to Some(a, b) #274
Comments
I can't test it on a local install at the moment, but it's reproducible on the playground. Click "format" https://rescript-lang.org/try?code=DYUwLgBAHhC8EGUD2BbEAKdBGANBATAJSFA Regardless of the formatter preference, I wonder if |
this is a bug in the playground when formatting code. Will fix. |
Configure the parser to pass forPrinter:true when parsing / printing ReScript. This fixes issues where e.g. Some((1, 2)) get misprinted to Some(1,2) etc. Relevant bug reports: - rescript-lang/syntax#274 - rescript-lang/syntax#265
Should now be fixed on the playground: |
Thanks for the work, this is great. |
I'm still curious if both of these are supposed to compile the same: let a = Some((1, 2))
let b = Some(1, 2) Right now, either one compiles identically (and the formatter doesn't seem to have a preference), but Sorry if this is the intended behavior, and thanks for fixing the playground. |
This is a technical consequence of ocaml's representation of your source code. We as humans think in terms of "multiple variant arguments", but internally in the compiler this is expressed as a tuple. In ReScript variant argument are written between parens: Does this make sense? |
I don't think that's true, and it's the reason for In OCaml there's a difference between
|
oh wait, yes, that has something to do with it. Bit fuzzy on the topic, but explicit_arity gets ppx'ed away right in Reason? So the second snippet becomes the first one? |
There's indeed a difference and historically it stemmed from ocaml's small syntactic ambiguity in that case, which then gets disambiguated later in the pipeline instead of at the syntax level. |
Configure the parser to pass forPrinter:true when parsing / printing ReScript. This fixes issues where e.g. Some((1, 2)) get misprinted to Some(1,2) etc. Relevant bug reports: - rescript-lang/syntax#274 - rescript-lang/syntax#265
Configure the parser to pass forPrinter:true when parsing / printing ReScript. This fixes issues where e.g. Some((1, 2)) get misprinted to Some(1,2) etc. Relevant bug reports: - rescript-lang/syntax#274 - rescript-lang/syntax#265
Configure the parser to pass forPrinter:true when parsing / printing ReScript. This fixes issues where e.g. Some((1, 2)) get misprinted to Some(1,2) etc. Relevant bug reports: - rescript-lang/syntax#274 - rescript-lang/syntax#265
Configure the parser to pass forPrinter:true when parsing / printing ReScript. This fixes issues where e.g. Some((1, 2)) get misprinted to Some(1,2) etc. Relevant bug reports: - rescript-lang/syntax#274 - rescript-lang/syntax#265
Configure the parser to pass forPrinter:true when parsing / printing ReScript. This fixes issues where e.g. Some((1, 2)) get misprinted to Some(1,2) etc. Relevant bug reports: - rescript-lang/syntax#274 - rescript-lang/syntax#265
* Add all relevant changes from previous 2020 bundle API For reference on the previous work in 2020, refer to #4518 * Add ninja rule for building jsoo_refmt_main * Fix formatting edge-cases when formatting ReScript -> ReScript Configure the parser to pass forPrinter:true when parsing / printing ReScript. This fixes issues where e.g. Some((1, 2)) get misprinted to Some(1,2) etc. Relevant bug reports: - rescript-lang/syntax#274 - rescript-lang/syntax#265 * Introduce initial type hints in playground bundle results * Adapt playground to newest internal syntax apis * Make jsoo_refmt_main work again by removing refmt * Rename jsoo_refmt_main to jsoo_playground_main * Move jsoo_playground_main to jscomp/main * Remove irrelevant code * Remove Refmt_api * Make repl.js more reliable with missing .mli files * repl.js: Log target compiler file, set js_playground_main as default * Update CONTRIBUTING to align with the renamed playground jsoo entrypoint Co-authored-by: Patrick Stapfer <[email protected]>
* Add all relevant changes from previous 2020 bundle API For reference on the previous work in 2020, refer to rescript-lang#4518 * Add ninja rule for building jsoo_refmt_main * Fix formatting edge-cases when formatting ReScript -> ReScript Configure the parser to pass forPrinter:true when parsing / printing ReScript. This fixes issues where e.g. Some((1, 2)) get misprinted to Some(1,2) etc. Relevant bug reports: - rescript-lang/syntax#274 - rescript-lang/syntax#265 * Introduce initial type hints in playground bundle results * Adapt playground to newest internal syntax apis * Make jsoo_refmt_main work again by removing refmt * Rename jsoo_refmt_main to jsoo_playground_main * Move jsoo_playground_main to jscomp/main * Remove irrelevant code * Remove Refmt_api * Make repl.js more reliable with missing .mli files * repl.js: Log target compiler file, set js_playground_main as default * Update CONTRIBUTING to align with the renamed playground jsoo entrypoint Co-authored-by: Patrick Stapfer <[email protected]>
formats to:
Either one compiles, so maybe this isn’t a bug? The syntax is misleading, though, since the
Some
constructor only takes one value.This happens with other variant constructors as well.
The text was updated successfully, but these errors were encountered: