Commit f417b4aa authored by Sathya Gunasekaran's avatar Sathya Gunasekaran

[class] Fix early error for duplicate private fields

Bug: v8:8656
Change-Id: I86f00d377ac99a065c4ecf02abed08ec4feb3686
Reviewed-on: https://chromium-review.googlesource.com/c/1401214Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58650}
parent 82e9aa59
......@@ -1251,7 +1251,10 @@ class PreParser : public ParserBase<PreParser> {
class_info->computed_field_count),
VariableMode::kConst);
} else if (is_private && property_name.string_ != nullptr) {
scope()->DeclareVariableName(property_name.string_, VariableMode::kConst);
if (scope()->DeclareVariableName(property_name.string_,
VariableMode::kConst) == nullptr) {
ReportUnidentifiableError();
}
}
}
......
......@@ -5833,6 +5833,10 @@ TEST(PrivateClassFieldsErrors) {
"#async a = 0",
"#async a",
"#a; #a",
"#a = 1; #a",
"#a; #a = 1;",
"#constructor",
"#constructor = function() {}",
......@@ -6010,6 +6014,9 @@ TEST(PrivateStaticClassFieldsErrors) {
"#a = f(arguments)",
"#a = () => () => arguments",
"#a; static #a",
"static #a; #a",
// TODO(joyee): support static private methods
"static #a() { }",
"static get #a() { }",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment