Skip to content

Commit

Permalink
Fix outcome printing of uncurried higher order function types (#6323)
Browse files Browse the repository at this point in the history
  • Loading branch information
glennsl authored Jul 8, 2023
1 parent 18a2f2f commit 4617cbf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
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
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(() => ())

0 comments on commit 4617cbf

Please sign in to comment.