Skip to content

Commit 9e8d278

Browse files
authored
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.
1 parent 7c9cf46 commit 9e8d278

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

quickjs.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15112,7 +15112,8 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
1511215112
idx = get_u16(pc);
1511315113
pc += 2;
1511415114
if (unlikely(JS_IsUninitialized(var_buf[idx]))) {
15115-
JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, FALSE);
15115+
JS_ThrowReferenceErrorUninitialized2(caller_ctx, b, idx,
15116+
FALSE);
1511615117
goto exception;
1511715118
}
1511815119
sp[0] = JS_DupValue(ctx, var_buf[idx]);
@@ -15125,7 +15126,8 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
1512515126
idx = get_u16(pc);
1512615127
pc += 2;
1512715128
if (unlikely(JS_IsUninitialized(var_buf[idx]))) {
15128-
JS_ThrowReferenceErrorUninitialized2(ctx, b, idx, FALSE);
15129+
JS_ThrowReferenceErrorUninitialized2(caller_ctx, b, idx,
15130+
FALSE);
1512915131
goto exception;
1513015132
}
1513115133
set_value(ctx, &var_buf[idx], sp[-1]);
@@ -15138,7 +15140,8 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
1513815140
idx = get_u16(pc);
1513915141
pc += 2;
1514015142
if (unlikely(!JS_IsUninitialized(var_buf[idx]))) {
15141-
JS_ThrowReferenceError(ctx, "'this' can be initialized only once");
15143+
JS_ThrowReferenceError(caller_ctx,
15144+
"'this' can be initialized only once");
1514215145
goto exception;
1514315146
}
1514415147
set_value(ctx, &var_buf[idx], sp[-1]);

test262_errors.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-brok
55
test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedStart-broken-promise.js:34: strict mode: TypeError: $DONE() not called
66
test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-broken-promise-try-catch.js:39: TypeError: $DONE() not called
77
test262/test/built-ins/AsyncGeneratorPrototype/return/return-suspendedYield-broken-promise-try-catch.js:39: strict mode: TypeError: $DONE() not called
8-
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
9-
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
108
test262/test/built-ins/RegExp/lookahead-quantifier-match-groups.js:27: Test262Error: Expected [a, abc] and [a, undefined] to have the same contents. ? quantifier
119
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
1210
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.)

0 commit comments

Comments
 (0)