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 Sep 8, 2024
1 parent a39f1fc commit ded2d06
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# 12.0.0-alpha.4 (Unreleased)

#### :bug: Bug fix
- Fix tuple coercion. https://github.com/rescript-lang/rescript-compiler/pull/7024

# 12.0.0-alpha.3

#### :bug: Bug fix
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 @@ -1823,6 +1823,7 @@ and parse_constrained_expr_region p =
| token when Grammar.is_expr_start token -> (
let expr = parse_expr p in
match p.Parser.token with
| ColonGreaterThan -> Some (parse_coerced_expr ~expr p)
| Colon ->
Parser.next p;
let typ = parse_typ_expr 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 = ((Function$ (fun (x : int) -> (x :> int)))[@res.arity 1])
let foo = ((Function$ (fun x -> ((x : t) :> int)))[@res.arity 1])
let foo = ((Function$ (fun x -> ((x : t) :> int)))[@res.arity 1])
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 ded2d06

Please sign in to comment.