Use ReferenceError from right realm/context (#107)

The "this is not initialized" ReferenceError for a class C defined in
context B but instantiated in context A should be an instance of the
ReferenceError from A, not B.
This commit is contained in:
Ben Noordhuis 2023-11-21 19:24:15 +01:00 committed by GitHub
parent 7c9cf46f97
commit 9e8d278161
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

@ -15112,7 +15112,8 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
idx = get_u16(pc);
pc += 2;
if (unlikely(JS_IsUninitialized(var_buf[idx]))) {
JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, FALSE);
JS_ThrowReferenceErrorUninitialized2(caller_ctx, b, idx,
FALSE);
goto exception;
}
sp[0] = JS_DupValue(ctx, var_buf[idx]);
@ -15125,7 +15126,8 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
idx = get_u16(pc);
pc += 2;
if (unlikely(JS_IsUninitialized(var_buf[idx]))) {
JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, FALSE);
JS_ThrowReferenceErrorUninitialized2(caller_ctx, b, idx,
FALSE);
goto exception;
}
set_value(ctx, &var_buf[idx], sp[-1]);
@ -15138,7 +15140,8 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
idx = get_u16(pc);
pc += 2;
if (unlikely(!JS_IsUninitialized(var_buf[idx]))) {
JS_ThrowReferenceError(ctx, "'this' can be initialized only once");
JS_ThrowReferenceError(caller_ctx,
"'this' can be initialized only once");
goto exception;
}
set_value(ctx, &var_buf[idx], sp[-1]);

View file

@ -5,8 +5,6 @@ test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-brok
test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-broken-promise.js:34: strict mode: TypeError: $DONE() not called
test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-broken-promise-try-catch.js:39: TypeError: $DONE() not called
test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-broken-promise-try-catch.js:39: strict mode: TypeError: $DONE() not called
test262/test/built-ins/Function/internals/Construct/derived-this-uninitialized-realm.js:20: Test262Error: Expected a ReferenceError but got a different error constructor with the same name
test262/test/built-ins/Function/internals/Construct/derived-this-uninitialized-realm.js:20: strict mode: Test262Error: Expected a ReferenceError but got a different error constructor with the same name
test262/test/built-ins/RegExp/lookahead-quantifier-match-groups.js:27: Test262Error: Expected [a, abc] and [a, undefined] to have the same contents. ? quantifier
test262/test/built-ins/RegExp/lookahead-quantifier-match-groups.js:27: strict mode: Test262Error: Expected [a, abc] and [a, undefined] to have the same contents. ? quantifier
test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js:30: TypeError: out-of-bound numeric index (Testing with Float64Array.)