diff --git a/CHANGELOG.md b/CHANGELOG.md index d9b878c37c..d916087444 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/jscomp/syntax/src/res_outcome_printer.ml b/jscomp/syntax/src/res_outcome_printer.ml index da54dc626a..7ec8069b0d 100644 --- a/jscomp/syntax/src/res_outcome_printer.ml +++ b/jscomp/syntax/src/res_outcome_printer.ml @@ -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 diff --git a/jscomp/syntax/src/res_printer.ml b/jscomp/syntax/src/res_printer.ml index 0bdfaa1b4e..a386461bad 100644 --- a/jscomp/syntax/src/res_printer.ml +++ b/jscomp/syntax/src/res_printer.ml @@ -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 diff --git a/jscomp/syntax/tests/oprint/expected/oprint.resi.txt b/jscomp/syntax/tests/oprint/expected/oprint.resi.txt index 4eba8c6704..d2cce10ab0 100644 --- a/jscomp/syntax/tests/oprint/expected/oprint.resi.txt +++ b/jscomp/syntax/tests/oprint/expected/oprint.resi.txt @@ -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 @@ -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} \ No newline at end of file +type opt = {x: int, y?: option} +let secondOrder: (unit => 'a) => 'a +let thirdOrder: ((unit => unit) => 'a) => 'a \ No newline at end of file diff --git a/jscomp/syntax/tests/oprint/oprint.res b/jscomp/syntax/tests/oprint/oprint.res index 4e0a3d35f5..3af354a61f 100644 --- a/jscomp/syntax/tests/oprint/oprint.res +++ b/jscomp/syntax/tests/oprint/oprint.res @@ -308,3 +308,6 @@ type call = CleanStart let f = (~a=1, ()) => 1 type opt = {x:int, y?: option} + +let secondOrder = f => f() +let thirdOrder = f => f(() => ())