Skip to content

Commit 864a664

Browse files
Fabrice Bellardsaghul
authored andcommitted
Raise an error if a private method is added twice to an object
1 parent b51b510 commit 864a664

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

quickjs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7261,6 +7261,12 @@ static int JS_AddBrand(JSContext *ctx, JSValue obj, JSValue home_obj)
72617261
return -1;
72627262
}
72637263
p1 = JS_VALUE_GET_OBJ(obj);
7264+
prs = find_own_property(&pr, p1, brand_atom);
7265+
if (unlikely(prs)) {
7266+
JS_FreeAtom(ctx, brand_atom);
7267+
JS_ThrowTypeError(ctx, "private method is already present");
7268+
return -1;
7269+
}
72647270
pr = add_property(ctx, p1, brand_atom, JS_PROP_C_W_E);
72657271
JS_FreeAtom(ctx, brand_atom);
72667272
if (!pr)

test262_errors.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,5 @@ test262/test/language/statements/async-generator/yield-star-promise-not-unwrappe
4444
test262/test/language/statements/async-generator/yield-star-promise-not-unwrapped.js:25: strict mode: TypeError: $DONE() not called
4545
test262/test/language/statements/async-generator/yield-star-return-then-getter-ticks.js:131: TypeError: $DONE() not called
4646
test262/test/language/statements/async-generator/yield-star-return-then-getter-ticks.js:131: strict mode: TypeError: $DONE() not called
47-
test262/test/language/statements/class/elements/private-method-double-initialisation-get-and-set.js:33: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
48-
test262/test/language/statements/class/elements/private-method-double-initialisation-get-and-set.js:33: strict mode: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
49-
test262/test/language/statements/class/elements/private-method-double-initialisation-get.js:32: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
50-
test262/test/language/statements/class/elements/private-method-double-initialisation-get.js:32: strict mode: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
51-
test262/test/language/statements/class/elements/private-method-double-initialisation-set.js:32: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
52-
test262/test/language/statements/class/elements/private-method-double-initialisation-set.js:32: strict mode: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
53-
test262/test/language/statements/class/elements/private-method-double-initialisation.js:32: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
54-
test262/test/language/statements/class/elements/private-method-double-initialisation.js:32: strict mode: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
5547
test262/test/language/statements/for-of/head-lhs-async-invalid.js:14: unexpected error type: Test262: This statement should not be evaluated.
5648
test262/test/language/statements/for-of/head-lhs-async-invalid.js:14: strict mode: unexpected error type: Test262: This statement should not be evaluated.

0 commit comments

Comments
 (0)