Skip to content

Commit

Permalink
Fix tuple coercion (#7024)
Browse files Browse the repository at this point in the history
* Fix tuple coercion

It was only handled for the first arg in the tuple

* Update CHANGELOG
  • Loading branch information
shulhi authored and cknitt committed Sep 10, 2024
1 parent 49e702f commit 3d8ca49
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Disallow spreading anything but regular variants inside of other variants. https://github.com/rescript-lang/rescript-compiler/pull/6980
- Fix comment removed when function signature has `type` keyword. https://github.com/rescript-lang/rescript-compiler/pull/6997
- Fix parse error on doc comment before "and" in type def. https://github.com/rescript-lang/rescript-compiler/pull/7001
- Fix tuple coercion. https://github.com/rescript-lang/rescript-compiler/pull/7024

# 11.1.3

Expand Down
1 change: 1 addition & 0 deletions jscomp/syntax/src/res_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,7 @@ and parseConstrainedExprRegion p =
| token when Grammar.isExprStart token -> (
let expr = parseExpr p in
match p.Parser.token with
| ColonGreaterThan -> Some (parseCoercedExpr ~expr p)
| Colon ->
Parser.next p;
let typ = parseTypExpr p in
Expand Down
10 changes: 9 additions & 1 deletion jscomp/syntax/tests/parsing/grammar/expressions/coerce.res
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
let foo = (x:int) => (x :> int)

let foo = x => (x : t :> int)
let foo = x => (x : t :> int)

let _ = (x : int)

let foo = (x : int, y :> float)

let foo = (x : int, y :> float, z :> int)

let foo = (x : int, y, z :> int)
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
let foo (x : int) = (x :> int)
let foo x = ((x : t) :> int)
let foo x = ((x : t) :> int)
let _ = (x : int)
let foo = ((x : int), (y :> float))
let foo = ((x : int), (y :> float), (z :> int))
let foo = ((x : int), y, (z :> int))

0 comments on commit 3d8ca49

Please sign in to comment.