Skip to content

Commit 3d8ca49

Browse files
shulhicknitt
authored andcommitted
Fix tuple coercion (#7024)
* Fix tuple coercion It was only handled for the first arg in the tuple * Update CHANGELOG
1 parent 49e702f commit 3d8ca49

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Disallow spreading anything but regular variants inside of other variants. https://github.com/rescript-lang/rescript-compiler/pull/6980
1919
- Fix comment removed when function signature has `type` keyword. https://github.com/rescript-lang/rescript-compiler/pull/6997
2020
- Fix parse error on doc comment before "and" in type def. https://github.com/rescript-lang/rescript-compiler/pull/7001
21+
- Fix tuple coercion. https://github.com/rescript-lang/rescript-compiler/pull/7024
2122

2223
# 11.1.3
2324

jscomp/syntax/src/res_core.ml

+1
Original file line numberDiff line numberDiff line change
@@ -1865,6 +1865,7 @@ and parseConstrainedExprRegion p =
18651865
| token when Grammar.isExprStart token -> (
18661866
let expr = parseExpr p in
18671867
match p.Parser.token with
1868+
| ColonGreaterThan -> Some (parseCoercedExpr ~expr p)
18681869
| Colon ->
18691870
Parser.next p;
18701871
let typ = parseTypExpr p in
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
let foo = (x:int) => (x :> int)
22

3-
let foo = x => (x : t :> int)
3+
let foo = x => (x : t :> int)
4+
5+
let _ = (x : int)
6+
7+
let foo = (x : int, y :> float)
8+
9+
let foo = (x : int, y :> float, z :> int)
10+
11+
let foo = (x : int, y, z :> int)
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
let foo (x : int) = (x :> int)
2-
let foo x = ((x : t) :> int)
2+
let foo x = ((x : t) :> int)
3+
let _ = (x : int)
4+
let foo = ((x : int), (y :> float))
5+
let foo = ((x : int), (y :> float), (z :> int))
6+
let foo = ((x : int), y, (z :> int))

0 commit comments

Comments
 (0)