Skip to content

Commit d90d453

Browse files
nicolo-ribaudoV8 LUCI CQ
authored andcommitted
Fix reading integer-indexed import assertions in dynamic import
Use GetPropertyOrElement instead of GetProperty to read import assertion values from the import assertions object, to support cases in which the key is an integer index such as `"0"`. The added test case, when using GetProperty, triggers the following DCHECK in debug builds: https://source.chromium.org/chromium/chromium/src/+/main:v8/src/objects/lookup-inl.h;l=108;drc=515f187ba067ee4a99fdf5198cca2c97abd342fd In release builds it silently fails to read the property, and thus throws about it not being a valid string. Bug: v8:14069 Change-Id: Ifd4645b7bd9bfd07f06fa33727441d27eabc4d32 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4614489 Reviewed-by: Victor Gomes <victorgomes@chromium.org> Commit-Queue: Marja Hölttä <marja@chromium.org> Reviewed-by: Marja Hölttä <marja@chromium.org> Cr-Commit-Position: refs/heads/main@{#88267}
1 parent 1821a0c commit d90d453

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/execution/isolate.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5246,8 +5246,8 @@ MaybeHandle<FixedArray> Isolate::GetImportAssertionsFromArgument(
52465246
for (int i = 0; i < assertion_keys->length(); i++) {
52475247
Handle<String> assertion_key(String::cast(assertion_keys->get(i)), this);
52485248
Handle<Object> assertion_value;
5249-
if (!JSReceiver::GetProperty(this, import_assertions_object_receiver,
5250-
assertion_key)
5249+
if (!Object::GetPropertyOrElement(this, import_assertions_object_receiver,
5250+
assertion_key)
52515251
.ToHandle(&assertion_value)) {
52525252
// This can happen if the property has a getter function that throws
52535253
// an error.

test/mjsunit/harmony/modules-import-assertions-dynamic-6.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ var life;
88
import('modules-skip-1.json', { assert: { type: 'json', notARealAssertion: 'value' } }).then(
99
namespace => life = namespace.default.life);
1010

11+
var life2;
12+
import('modules-skip-1.json', { assert: { 0: 'value', type: 'json' } }).then(
13+
namespace => life2 = namespace.default.life);
14+
1115
%PerformMicrotaskCheckpoint();
1216

1317
assertEquals(42, life);
18+
assertEquals(42, life2);

0 commit comments

Comments
 (0)