Skip to content

Commit 4617cbf

Browse files
authored
Fix outcome printing of uncurried higher order function types (#6323)
1 parent 18a2f2f commit 4617cbf

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#### :boom: Breaking Change
1818
- 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
1919

20+
#### :bug: Bug Fix
21+
- Fixed outcome printing of uncurried higehr order function types. https://github.com/rescript-lang/rescript-compiler/pull/6323
22+
- Fixed printing of type constraints in template literal substitutions. https://github.com/rescript-lang/rescript-compiler/pull/6324
23+
2024
# 11.0.0-beta.3
2125

2226
#### :rocket: New Feature

jscomp/syntax/src/res_outcome_printer.ml

+6-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,12 @@ and printOutArrowType ~uncurried typ =
354354
let needsParens =
355355
match typArgs with
356356
| _ when uncurried -> true
357-
| [(_, (Otyp_tuple _ | Otyp_arrow _))] -> true
357+
| [
358+
( _,
359+
( Otyp_tuple _ | Otyp_arrow _
360+
| Otyp_constr (Oide_ident "function$", [Otyp_arrow _; _]) ) );
361+
] ->
362+
true
358363
(* single argument should not be wrapped *)
359364
| [("", _)] -> false
360365
| _ -> true

jscomp/syntax/tests/oprint/expected/oprint.resi.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ type permissions = [#644 | #777]
217217
type numericPolyVarWithPayload = [#1(string) | #2(int, string)]
218218
let numericPolyVarMatch: [> #1(string) | #2(int, string)]
219219
let sort: (module(Set.S with type elt = 'a), list<'a>) => list<'a>
220-
let make_set: ('a, 'a) => int => module(Set.S with type elt = 'a)
220+
let make_set: (('a, 'a) => int) => module(Set.S with type elt = 'a)
221221
type picture = string
222222
module type DEVICE = {
223223
let draw: picture => unit
@@ -237,4 +237,6 @@ type emptyObject = {.}
237237
let f: (~x: 'a=?, ~y: 'b) => option<'a>
238238
type call = CleanStart
239239
let f: (~a: int=?, unit) => int
240-
type opt = {x: int, y?: option<string>}
240+
type opt = {x: int, y?: option<string>}
241+
let secondOrder: (unit => 'a) => 'a
242+
let thirdOrder: ((unit => unit) => 'a) => 'a

jscomp/syntax/tests/oprint/oprint.res

+3
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,6 @@ type call = CleanStart
308308
let f = (~a=1, ()) => 1
309309

310310
type opt = {x:int, y?: option<string>}
311+
312+
let secondOrder = f => f()
313+
let thirdOrder = f => f(() => ())

0 commit comments

Comments
 (0)