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

Fix outcome printing of uncurried higher order function types #6323

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#### :boom: Breaking Change
- Fixed the issue of name collision between the newly defined Js.Json.t and the variant constructor in the existing Js.Json.kind type. To address this, the usage of the existing Js.Json.kind type can be updated to Js.Json.Kind.t. https://github.com/rescript-lang/rescript-compiler/pull/6317

#### :bug: Bug Fix
- Fixed outcome printing of uncurried higehr order function types. https://github.com/rescript-lang/rescript-compiler/pull/6323
- Fixed printing of type constraints in template literal substitutions. https://github.com/rescript-lang/rescript-compiler/pull/6324

# 11.0.0-beta.3

#### :rocket: New Feature
Expand Down
7 changes: 6 additions & 1 deletion jscomp/syntax/src/res_outcome_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,12 @@ and printOutArrowType ~uncurried typ =
let needsParens =
match typArgs with
| _ when uncurried -> true
| [(_, (Otyp_tuple _ | Otyp_arrow _))] -> true
| [
( _,
( Otyp_tuple _ | Otyp_arrow _
| Otyp_constr (Oide_ident "function$", [Otyp_arrow _; _]) ) );
] ->
true
(* single argument should not be wrapped *)
| [("", _)] -> false
| _ -> true
Expand Down
3 changes: 2 additions & 1 deletion jscomp/syntax/src/res_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,8 @@ and printConstructorDeclaration2 ~state i
printComments doc cmtTbl cd.pcd_name.loc
in
let constrArgs =
printConstructorArguments ~isDotDotDot ~state ~indent:true cd.pcd_args cmtTbl
printConstructorArguments ~isDotDotDot ~state ~indent:true cd.pcd_args
cmtTbl
in
let gadt =
match cd.pcd_res with
Expand Down
6 changes: 4 additions & 2 deletions jscomp/syntax/tests/oprint/expected/oprint.resi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ type permissions = [#644 | #777]
type numericPolyVarWithPayload = [#1(string) | #2(int, string)]
let numericPolyVarMatch: [> #1(string) | #2(int, string)]
let sort: (module(Set.S with type elt = 'a), list<'a>) => list<'a>
let make_set: ('a, 'a) => int => module(Set.S with type elt = 'a)
let make_set: (('a, 'a) => int) => module(Set.S with type elt = 'a)
type picture = string
module type DEVICE = {
let draw: picture => unit
Expand All @@ -237,4 +237,6 @@ type emptyObject = {.}
let f: (~x: 'a=?, ~y: 'b) => option<'a>
type call = CleanStart
let f: (~a: int=?, unit) => int
type opt = {x: int, y?: option<string>}
type opt = {x: int, y?: option<string>}
let secondOrder: (unit => 'a) => 'a
let thirdOrder: ((unit => unit) => 'a) => 'a
3 changes: 3 additions & 0 deletions jscomp/syntax/tests/oprint/oprint.res
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,6 @@ type call = CleanStart
let f = (~a=1, ()) => 1

type opt = {x:int, y?: option<string>}

let secondOrder = f => f()
let thirdOrder = f => f(() => ())