diff --git a/quickjs.c b/quickjs.c index e156a92..bdc0cc8 100644 --- a/quickjs.c +++ b/quickjs.c @@ -8159,15 +8159,27 @@ static JSValue JS_GetPropertyValue(JSContext *ctx, JSValue this_obj, { JSAtom atom; JSValue ret; + uint32_t tag; - if (likely(JS_VALUE_GET_TAG(this_obj) == JS_TAG_OBJECT && - JS_VALUE_GET_TAG(prop) == JS_TAG_INT)) { - JSObject *p = JS_VALUE_GET_OBJ(this_obj); - uint32_t idx = JS_VALUE_GET_INT(prop); - JSValue val; - /* fast path for array and typed array access */ - if (js_get_fast_array_element(ctx, p, idx, &val)) - return val; + tag = JS_VALUE_GET_TAG(this_obj); + if (likely(tag == JS_TAG_OBJECT)) { + if (JS_VALUE_GET_TAG(prop) == JS_TAG_INT) { + JSObject *p = JS_VALUE_GET_OBJ(this_obj); + uint32_t idx = JS_VALUE_GET_INT(prop); + JSValue val; + /* fast path for array and typed array access */ + if (js_get_fast_array_element(ctx, p, idx, &val)) + return val; + } + } else { + switch(tag) { + case JS_TAG_NULL: + JS_FreeValue(ctx, prop); + return JS_ThrowTypeError(ctx, "cannot read property of null"); + case JS_TAG_UNDEFINED: + JS_FreeValue(ctx, prop); + return JS_ThrowTypeError(ctx, "cannot read property of undefined"); + } } atom = JS_ValueToAtom(ctx, prop); JS_FreeValue(ctx, prop); diff --git a/test262_errors.txt b/test262_errors.txt index 89eb9d3..f764e70 100644 --- a/test262_errors.txt +++ b/test262_errors.txt @@ -628,7 +628,5 @@ test262/test/language/expressions/assignment/target-super-computed-reference.js: test262/test/language/expressions/assignment/target-super-computed-reference.js:20: strict mode: Test262Error: Expected a DummyError but got a Test262Error test262/test/language/expressions/in/private-field-invalid-assignment-target.js:23: unexpected error type: Test262: This statement should not be evaluated. test262/test/language/expressions/in/private-field-invalid-assignment-target.js:23: strict mode: unexpected error type: Test262: This statement should not be evaluated. -test262/test/language/expressions/member-expression/computed-reference-null-or-undefined.js:28: Test262Error: Expected a TypeError but got a Test262Error -test262/test/language/expressions/member-expression/computed-reference-null-or-undefined.js:28: strict mode: Test262Error: Expected a TypeError but got a Test262Error test262/test/language/module-code/top-level-await/async-module-does-not-block-sibling-modules.js:13: SyntaxError: Could not find export 'check' in module 'test262/test/language/module-code/top-level-await/async-module-sync_FIXTURE.js' test262/test/staging/top-level-await/tla-hang-entry.js:10: TypeError: $DONE() not called