Report bad-class-member errors using a specified offset instead of a node's offset.

This commit is contained in:
wolfbeast 2019-04-06 07:30:00 +02:00 committed by Roy Tam
commit 42d2e161db

View file

@ -6673,7 +6673,7 @@ Parser<ParseHandler>::classDefinition(YieldHandling yieldHandling,
propType != PropertyType::AsyncMethod &&
propType != PropertyType::Constructor && propType != PropertyType::DerivedConstructor)
{
error(JSMSG_BAD_METHOD_DEF);
errorAt(nameOffset, JSMSG_BAD_METHOD_DEF);
return null();
}
@ -6683,17 +6683,17 @@ Parser<ParseHandler>::classDefinition(YieldHandling yieldHandling,
propType = PropertyType::SetterNoExpressionClosure;
if (!isStatic && propAtom == context->names().constructor) {
if (propType != PropertyType::Method) {
reportWithNode(ParseError, false, propName, JSMSG_BAD_METHOD_DEF);
errorAt(nameOffset, JSMSG_BAD_METHOD_DEF);
return null();
}
if (seenConstructor) {
reportWithNode(ParseError, false, propName, JSMSG_DUPLICATE_PROPERTY, "constructor");
errorAt(nameOffset, JSMSG_DUPLICATE_PROPERTY, "constructor");
return null();
}
seenConstructor = true;
propType = hasHeritage ? PropertyType::DerivedConstructor : PropertyType::Constructor;
} else if (isStatic && propAtom == context->names().prototype) {
reportWithNode(ParseError, false, propName, JSMSG_BAD_METHOD_DEF);
errorAt(nameOffset, JSMSG_BAD_METHOD_DEF);
return null();
}