Skip to content

Support {} for empty inlined record literals and types #5900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 12, 2022
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ These are only breaking changes for unformatted code.

# 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
Expand Down
1 change: 1 addition & 0 deletions jscomp/ml/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,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
Expand Down
8 changes: 8 additions & 0 deletions jscomp/test/record_regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
4 changes: 4 additions & 0 deletions jscomp/test/record_regression.res
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,7 @@ let inlinedRecord = ir =>
}
let pm3 = inlinedRecord(ir2)
let pm4 = inlinedRecord(ir3)

type inlinedOptional2 = V0({x?: int})
let ir4 = V0({x: 3})
let ir5 = V0({})