Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#### :nail_care: Polish
- Removed duplicate Super_error implementation in syntax https://github.com/rescript-lang/rescript-compiler/pull/6246

#### :bug: Bug Fix
- Fix issue with inlining records in the presence of record coercion https://github.com/rescript-lang/rescript-compiler/pull/6256

# 11.0.0-alpha.6

#### :boom: Breaking Change
Expand Down
13 changes: 12 additions & 1 deletion jscomp/core/lam_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,18 @@ let field_flatten_get
| SimpleForm l -> l
| exception _ -> lam ()
end
| Some (Constant (Const_block (_,_,ls))) ->
| Some (Constant (Const_block (_, Blk_record {fields}, ls))) ->
(match info with
| Fld_record {name} ->
let found = ref None in
for i = 0 to Array.length fields - 1 do
if fields.(i) = name then found := Ext_list.nth_opt ls i done;
(match !found with
| Some c -> Lam.const c
| None -> lam())
| _ -> lam ()
)
| Some (Constant (Const_block (_,_,ls))) ->
begin match Ext_list.nth_opt ls i with
| None -> lam ()
| Some x -> Lam.const x
Expand Down
16 changes: 15 additions & 1 deletion jscomp/test/RecordCoercion.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions jscomp/test/RecordCoercion.res
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,19 @@ let _ = (x: r3) => (x :> r4) // omit everything
type nested1 = {n: r1, extra: int}
type nested2 = {n: r2}
let _ = (x: nested1) => (x :> nested2)

module TestInlining = {
type a = {
number: int,
name: string,
}

type b = {name: string}

let a: a = {
number: 42,
name: "a",
}

let name = (a :> b).name
}