Skip to content

Commit 80d53a6

Browse files
nshahanCommit Queue
authored and
Commit Queue
committed
[ddc] Coerce undefined to null in record elements
Fixes: #52593 Change-Id: Ic8b05f8a3a0251dd8774af076f6f226c5c652bc5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308245 Commit-Queue: Nicholas Shahan <[email protected]> Reviewed-by: Mark Zhou <[email protected]>
1 parent dd27b43 commit 80d53a6

File tree

1 file changed

+11
-1
lines changed
  • sdk/lib/_internal/js_dev_runtime/private/ddc_runtime

1 file changed

+11
-1
lines changed

sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/records.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,17 @@ final class RecordImpl implements Record {
3838
/// NOTE: Does not contain the cached result of the "safe" [_toString] call.
3939
String? _printed;
4040

41-
RecordImpl(this.shape, this.values);
41+
RecordImpl(this.shape, this.values) {
42+
var valueCount = JS<int>('!', '#.length', values);
43+
// Coerce all undefined values to null because dynamic gets of record
44+
// elements rely on the getter returning undefined to signal that the getter
45+
// does not exist.
46+
for (int i = 0; i < valueCount; i++) {
47+
if (JS<bool>('!', '#[#] === void 0', values, i)) {
48+
JS('', '#[#] = null', values, i);
49+
}
50+
}
51+
}
4252

4353
@override
4454
bool operator ==(Object? other) {

0 commit comments

Comments
 (0)