Skip to content

Commit 50aa83e

Browse files
authored
(v10.1) Support {} for empty inlined record literals and types (#5901)
1 parent 46a1fcf commit 50aa83e

7 files changed

+20
-0
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
1313
# 10.1.1
1414

15+
#### :rocket: New Feature
16+
17+
- Add support for empty inlined record literal `{}` for inlined records where all fields are optional https://github.com/rescript-lang/rescript-compiler/pull/5900
18+
1519
#### :bug: Bug Fix
1620

1721
- Prevent inlining of async functions in additional cases https://github.com/rescript-lang/rescript-compiler/issues/5860

jscomp/ml/typecore.ml

+1
Original file line numberDiff line numberDiff line change
@@ -2138,6 +2138,7 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected =
21382138
| [], Some (representation) when lid_sexp_list = [] ->
21392139
let optional_labels = match representation with
21402140
| Record_optional_labels optional_labels -> optional_labels
2141+
| Record_inlined {optional_labels} -> optional_labels
21412142
| _ -> [] in
21422143
let filter_missing (ld : Types.label_declaration) =
21432144
let name = Ident.name ld.ld_id in

jscomp/test/record_regression.js

+8
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,12 @@ var h = newrecord$2;
257257

258258
var h10 = newrecord$3;
259259

260+
var ir4 = /* V0 */{
261+
x: 3
262+
};
263+
264+
var ir5 = /* V0 */{};
265+
260266
exports.f1 = f1;
261267
exports.f2 = f2;
262268
exports.f3 = f3;
@@ -280,4 +286,6 @@ exports.pm2 = pm2;
280286
exports.inlinedRecord = inlinedRecord;
281287
exports.pm3 = pm3;
282288
exports.pm4 = pm4;
289+
exports.ir4 = ir4;
290+
exports.ir5 = ir5;
283291
/* Not a pure module */

jscomp/test/record_regression.res

+4
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,7 @@ let inlinedRecord = ir => switch ir {
122122
}
123123
let pm3 = inlinedRecord(ir2)
124124
let pm4 = inlinedRecord(ir3)
125+
126+
type inlinedOptional2 = V0({x?: int})
127+
let ir4 = V0({x: 3})
128+
let ir5 = V0({})

lib/4.06.1/unstable/js_compiler.ml

+1
Original file line numberDiff line numberDiff line change
@@ -42863,6 +42863,7 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected =
4286342863
| [], Some (representation) when lid_sexp_list = [] ->
4286442864
let optional_labels = match representation with
4286542865
| Record_optional_labels optional_labels -> optional_labels
42866+
| Record_inlined {optional_labels} -> optional_labels
4286642867
| _ -> [] in
4286742868
let filter_missing (ld : Types.label_declaration) =
4286842869
let name = Ident.name ld.ld_id in

lib/4.06.1/unstable/js_playground_compiler.ml

+1
Original file line numberDiff line numberDiff line change
@@ -42863,6 +42863,7 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected =
4286342863
| [], Some (representation) when lid_sexp_list = [] ->
4286442864
let optional_labels = match representation with
4286542865
| Record_optional_labels optional_labels -> optional_labels
42866+
| Record_inlined {optional_labels} -> optional_labels
4286642867
| _ -> [] in
4286742868
let filter_missing (ld : Types.label_declaration) =
4286842869
let name = Ident.name ld.ld_id in

lib/4.06.1/whole_compiler.ml

+1
Original file line numberDiff line numberDiff line change
@@ -219035,6 +219035,7 @@ and type_expect_ ?in_function ?(recarg=Rejected) env sexp ty_expected =
219035219035
| [], Some (representation) when lid_sexp_list = [] ->
219036219036
let optional_labels = match representation with
219037219037
| Record_optional_labels optional_labels -> optional_labels
219038+
| Record_inlined {optional_labels} -> optional_labels
219038219039
| _ -> [] in
219039219040
let filter_missing (ld : Types.label_declaration) =
219040219041
let name = Ident.name ld.ld_id in

0 commit comments

Comments
 (0)