summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2025-04-15 11:26:53 +0200
committerFabrice Bellard <fabrice@bellard.org>2025-04-15 11:26:53 +0200
commit5449fd42d62e5f3fda38736475f7c65c133b5cd2 (patch)
tree7a878f44daf74f2a7c34c4819fbbbc0755416537
parent8f99de5b7faa82d07e0ebd5489f6e99a8554d77c (diff)
downloadquickjs-5449fd42d62e5f3fda38736475f7c65c133b5cd2.tar.gz
quickjs-5449fd42d62e5f3fda38736475f7c65c133b5cd2.zip
more ToPropertyKey ordering changes
-rw-r--r--TODO2
-rw-r--r--quickjs.c9
-rw-r--r--test262_errors.txt4
3 files changed, 10 insertions, 5 deletions
diff --git a/TODO b/TODO
index c335c64..d4de648 100644
--- a/TODO
+++ b/TODO
@@ -62,6 +62,6 @@ Optimization ideas:
Test262o: 0/11262 errors, 463 excluded
Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch)
-Result: 14/76964 errors, 3147 excluded, 6912 skipped
+Result: 10/76964 errors, 3147 excluded, 6912 skipped
Test262 commit: 56e77d6325067a545ea7e8ff5be5d9284334e33c
diff --git a/quickjs.c b/quickjs.c
index 31375c5..4187cab 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -8355,6 +8355,11 @@ static JSValue JS_GetPropertyValue(JSContext *ctx, JSValueConst this_obj,
}
} else {
slow_path:
+ /* ToObject() must be done before ToPropertyKey() */
+ if (JS_IsNull(this_obj) || JS_IsUndefined(this_obj)) {
+ JS_FreeValue(ctx, prop);
+ return JS_ThrowTypeError(ctx, "cannot read property of %s", JS_IsNull(this_obj) ? "null" : "undefined");
+ }
atom = JS_ValueToAtom(ctx, prop);
JS_FreeValue(ctx, prop);
if (unlikely(atom == JS_ATOM_NULL))
@@ -22789,6 +22794,10 @@ static __exception int js_parse_object_literal(JSParseState *s)
}
emit_u8(s, op_flags | OP_DEFINE_METHOD_ENUMERABLE);
} else {
+ if (name == JS_ATOM_NULL) {
+ /* must be done before evaluating expr */
+ emit_op(s, OP_to_propkey);
+ }
if (js_parse_expect(s, ':'))
goto fail;
if (js_parse_assign_expr(s))
diff --git a/test262_errors.txt b/test262_errors.txt
index 2d098d0..0baea7b 100644
--- a/test262_errors.txt
+++ b/test262_errors.txt
@@ -1,10 +1,6 @@
test262/test/language/destructuring/binding/keyed-destructuring-property-reference-target-evaluation-order-with-bindings.js:73: Test262Error: Actual [binding::source, binding::sourceKey, sourceKey, get source, binding::defaultValue, binding::varTarget] and expected [binding::source, binding::sourceKey, sourceKey, binding::varTarget, get source, binding::defaultValue] should have the same contents.
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/expressions/object/computed-property-name-topropertykey-before-value-evaluation.js:31: Test262Error: Expected SameValue(«"bad"», «"ok"») to be true
-test262/test/language/expressions/object/computed-property-name-topropertykey-before-value-evaluation.js:31: strict mode: Test262Error: Expected SameValue(«"bad"», «"ok"») to be true
test262/test/language/module-code/top-level-await/module-graphs-does-not-hang.js:10: TypeError: $DONE() not called
test262/test/language/statements/with/get-binding-value-call-with-proxy-env.js:39: Test262Error: Actual [has:Object, get:Symbol(Symbol.unscopables), get:Object] and expected [has:Object, get:Symbol(Symbol.unscopables), has:Object, get:Object] should have the same contents.
test262/test/language/statements/with/get-binding-value-idref-with-proxy-env.js:39: Test262Error: Actual [has:Object, get:Symbol(Symbol.unscopables), get:Object] and expected [has:Object, get:Symbol(Symbol.unscopables), has:Object, get:Object] should have the same contents.