fixed duplicate static private setter/getter test

This commit is contained in:
Fabrice Bellard 2023-12-09 12:32:32 +01:00 committed by Ben Noordhuis
parent e8b97048d4
commit baf50f9236
2 changed files with 12 additions and 15 deletions

View file

@ -521,6 +521,7 @@ typedef struct JSVarDef {
uint8_t is_const : 1;
uint8_t is_lexical : 1;
uint8_t is_captured : 1;
uint8_t is_static_private : 1; /* only used during private class field parsing */
uint8_t var_kind : 4; /* see JSVarKindEnum */
/* only used during compilation: function pool index for lexical
variables with var_kind =
@ -20098,7 +20099,7 @@ static int define_var(JSParseState *s, JSFunctionDef *fd, JSAtom name,
/* add a private field variable in the current scope */
static int add_private_class_field(JSParseState *s, JSFunctionDef *fd,
JSAtom name, JSVarKindEnum var_kind)
JSAtom name, JSVarKindEnum var_kind, BOOL is_static)
{
JSContext *ctx = s->ctx;
JSVarDef *vd;
@ -20110,6 +20111,7 @@ static int add_private_class_field(JSParseState *s, JSFunctionDef *fd,
vd = &fd->vars[idx];
vd->is_lexical = 1;
vd->is_const = 1;
vd->is_static_private = is_static;
return idx;
}
@ -21139,20 +21141,23 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr,
JSFunctionDef *method_fd;
if (is_private) {
int idx, var_kind;
int idx, var_kind, is_static1;
idx = find_private_class_field(ctx, fd, name, fd->scope_level);
if (idx >= 0) {
var_kind = fd->vars[idx].var_kind;
is_static1 = fd->vars[idx].is_static_private;
if (var_kind == JS_VAR_PRIVATE_FIELD ||
var_kind == JS_VAR_PRIVATE_METHOD ||
var_kind == JS_VAR_PRIVATE_GETTER_SETTER ||
var_kind == (JS_VAR_PRIVATE_GETTER + is_set)) {
var_kind == (JS_VAR_PRIVATE_GETTER + is_set) ||
(var_kind == (JS_VAR_PRIVATE_GETTER + 1 - is_set) &&
is_static != is_static1)) {
goto private_field_already_defined;
}
fd->vars[idx].var_kind = JS_VAR_PRIVATE_GETTER_SETTER;
} else {
if (add_private_class_field(s, fd, name,
JS_VAR_PRIVATE_GETTER + is_set) < 0)
JS_VAR_PRIVATE_GETTER + is_set, is_static) < 0)
goto fail;
}
if (add_brand(s, &class_fields[is_static]) < 0)
@ -21178,7 +21183,7 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr,
goto fail;
emit_atom(s, setter_name);
ret = add_private_class_field(s, fd, setter_name,
JS_VAR_PRIVATE_SETTER);
JS_VAR_PRIVATE_SETTER, is_static);
JS_FreeAtom(ctx, setter_name);
if (ret < 0)
goto fail;
@ -21213,7 +21218,7 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr,
goto private_field_already_defined;
}
if (add_private_class_field(s, fd, name,
JS_VAR_PRIVATE_FIELD) < 0)
JS_VAR_PRIVATE_FIELD, is_static) < 0)
goto fail;
emit_op(s, OP_private_symbol);
emit_atom(s, name);
@ -21328,7 +21333,7 @@ static __exception int js_parse_class(JSParseState *s, BOOL is_class_expr,
goto fail;
}
if (add_private_class_field(s, fd, name,
JS_VAR_PRIVATE_METHOD) < 0)
JS_VAR_PRIVATE_METHOD, is_static) < 0)
goto fail;
emit_op(s, OP_set_home_object);
emit_op(s, OP_set_name);

View file

@ -117,13 +117,5 @@ test262/test/language/statements/class/elements/private-method-double-initialisa
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
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
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
test262/test/language/statements/class/private-non-static-getter-static-setter-early-error.js:13: unexpected error type: Test262: This statement should not be evaluated.
test262/test/language/statements/class/private-non-static-getter-static-setter-early-error.js:13: strict mode: unexpected error type: Test262: This statement should not be evaluated.
test262/test/language/statements/class/private-non-static-setter-static-getter-early-error.js:13: unexpected error type: Test262: This statement should not be evaluated.
test262/test/language/statements/class/private-non-static-setter-static-getter-early-error.js:13: strict mode: unexpected error type: Test262: This statement should not be evaluated.
test262/test/language/statements/class/private-static-getter-non-static-setter-early-error.js:13: unexpected error type: Test262: This statement should not be evaluated.
test262/test/language/statements/class/private-static-getter-non-static-setter-early-error.js:13: strict mode: unexpected error type: Test262: This statement should not be evaluated.
test262/test/language/statements/class/private-static-setter-non-static-getter-early-error.js:13: unexpected error type: Test262: This statement should not be evaluated.
test262/test/language/statements/class/private-static-setter-non-static-getter-early-error.js:13: strict mode: unexpected error type: Test262: This statement should not be evaluated.
test262/test/language/statements/for-of/head-lhs-async-invalid.js:14: unexpected error type: Test262: This statement should not be evaluated.
test262/test/language/statements/for-of/head-lhs-async-invalid.js:14: strict mode: unexpected error type: Test262: This statement should not be evaluated.