From d9c8af402605078ab4d5be4cb6b93f36cfa86973 Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Mon, 12 Dec 2022 23:45:15 +0900 Subject: [PATCH 1/4] add test --- jscomp/test/record_regression.res | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jscomp/test/record_regression.res b/jscomp/test/record_regression.res index 2c244fd257..285d91db3a 100644 --- a/jscomp/test/record_regression.res +++ b/jscomp/test/record_regression.res @@ -122,3 +122,7 @@ let inlinedRecord = ir => switch ir { } let pm3 = inlinedRecord(ir2) let pm4 = inlinedRecord(ir3) + +type inlinedOptional2 = V0({x?: int}) +let ir4 = V0({x: 3}) +let ir5 = V0({}) \ No newline at end of file From 4a9484f953fecd1cf9d972b6487c2d8f26dbd015 Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Mon, 12 Dec 2022 23:47:56 +0900 Subject: [PATCH 2/4] fix type error of empty inlined record --- jscomp/ml/typecore.ml | 1 + jscomp/test/record_regression.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/jscomp/ml/typecore.ml b/jscomp/ml/typecore.ml index afc9488684..6b9ad8d7d8 100644 --- a/jscomp/ml/typecore.ml +++ b/jscomp/ml/typecore.ml @@ -2138,6 +2138,7 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = | [], Some (representation) when lid_sexp_list = [] -> let optional_labels = match representation with | Record_optional_labels optional_labels -> optional_labels + | Record_inlined {optional_labels} -> optional_labels | _ -> [] in let filter_missing (ld : Types.label_declaration) = let name = Ident.name ld.ld_id in diff --git a/jscomp/test/record_regression.js b/jscomp/test/record_regression.js index a8fc24cdb3..10454cf225 100644 --- a/jscomp/test/record_regression.js +++ b/jscomp/test/record_regression.js @@ -257,6 +257,12 @@ var h = newrecord$2; var h10 = newrecord$3; +var ir4 = /* V0 */{ + x: 3 +}; + +var ir5 = /* V0 */{}; + exports.f1 = f1; exports.f2 = f2; exports.f3 = f3; @@ -280,4 +286,6 @@ exports.pm2 = pm2; exports.inlinedRecord = inlinedRecord; exports.pm3 = pm3; exports.pm4 = pm4; +exports.ir4 = ir4; +exports.ir5 = ir5; /* Not a pure module */ From 3c6abff432f96440404bc870ec36e608100e257e Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Tue, 13 Dec 2022 00:19:22 +0900 Subject: [PATCH 3/4] update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4265be1a70..4884a3505b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ # 10.1.1 +#### :rocket: New Feature + +- Add support for empty inlined record literal `{}` for inlined records where all fields are optional https://github.com/rescript-lang/rescript-compiler/pull/5900 + #### :bug: Bug Fix - Prevent inlining of async functions in additional cases https://github.com/rescript-lang/rescript-compiler/issues/5860 From 984f39358c324bcd4dcee6aa27576770d468ea87 Mon Sep 17 00:00:00 2001 From: Woonki Moon Date: Wed, 14 Dec 2022 09:05:11 +0900 Subject: [PATCH 4/4] snapshot --- lib/4.06.1/unstable/js_compiler.ml | 1 + lib/4.06.1/unstable/js_playground_compiler.ml | 1 + lib/4.06.1/whole_compiler.ml | 1 + 3 files changed, 3 insertions(+) diff --git a/lib/4.06.1/unstable/js_compiler.ml b/lib/4.06.1/unstable/js_compiler.ml index 54cfafa6c2..771a7aa968 100644 --- a/lib/4.06.1/unstable/js_compiler.ml +++ b/lib/4.06.1/unstable/js_compiler.ml @@ -42863,6 +42863,7 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = | [], Some (representation) when lid_sexp_list = [] -> let optional_labels = match representation with | Record_optional_labels optional_labels -> optional_labels + | Record_inlined {optional_labels} -> optional_labels | _ -> [] in let filter_missing (ld : Types.label_declaration) = let name = Ident.name ld.ld_id in diff --git a/lib/4.06.1/unstable/js_playground_compiler.ml b/lib/4.06.1/unstable/js_playground_compiler.ml index bceba48f7f..4ac6a2ac5d 100644 --- a/lib/4.06.1/unstable/js_playground_compiler.ml +++ b/lib/4.06.1/unstable/js_playground_compiler.ml @@ -42863,6 +42863,7 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = | [], Some (representation) when lid_sexp_list = [] -> let optional_labels = match representation with | Record_optional_labels optional_labels -> optional_labels + | Record_inlined {optional_labels} -> optional_labels | _ -> [] in let filter_missing (ld : Types.label_declaration) = let name = Ident.name ld.ld_id in diff --git a/lib/4.06.1/whole_compiler.ml b/lib/4.06.1/whole_compiler.ml index c05257f7f3..e6df123c2c 100644 --- a/lib/4.06.1/whole_compiler.ml +++ b/lib/4.06.1/whole_compiler.ml @@ -219035,6 +219035,7 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected = | [], Some (representation) when lid_sexp_list = [] -> let optional_labels = match representation with | Record_optional_labels optional_labels -> optional_labels + | Record_inlined {optional_labels} -> optional_labels | _ -> [] in let filter_missing (ld : Types.label_declaration) = let name = Ident.name ld.ld_id in