Make distinction between * method and * operator
Also add quotes to properties when necessary, this might be the case if the name isn't a valid identifier
This commit is contained in:
17
lib/parse.js
17
lib/parse.js
@@ -1747,7 +1747,7 @@ function parse($TEXT, options) {
|
||||
a.push(concise);
|
||||
continue;
|
||||
}
|
||||
} else if (start.value === "*") {
|
||||
} else if (name === null) {
|
||||
unexpected(prev());
|
||||
}
|
||||
|
||||
@@ -1844,14 +1844,13 @@ function parse($TEXT, options) {
|
||||
function concise_method_or_getset(name, start, is_class) {
|
||||
var get_ast = function(name, token) {
|
||||
if (typeof name === "string" || typeof name === "number") {
|
||||
if (name === "*") {
|
||||
unexpected(token);
|
||||
}
|
||||
return new AST_SymbolMethod({
|
||||
start: token,
|
||||
name: name,
|
||||
end: prev()
|
||||
});
|
||||
} else if (name === null) {
|
||||
unexpected();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
@@ -1861,9 +1860,12 @@ function parse($TEXT, options) {
|
||||
is_static = true;
|
||||
name = as_property_name();
|
||||
}
|
||||
if (name === "*") {
|
||||
if (name === null) {
|
||||
is_generator = true;
|
||||
name = as_property_name();
|
||||
if (name === null) {
|
||||
unexpected();
|
||||
}
|
||||
}
|
||||
if (is("punc", "(")) {
|
||||
name = get_ast(name, start);
|
||||
@@ -2017,7 +2019,10 @@ function parse($TEXT, options) {
|
||||
return ex;
|
||||
} else unexpected(tmp);
|
||||
case "operator":
|
||||
if (["*", "delete", "in", "instanceof", "new", "typeof", "void"].indexOf(tmp.value) === -1) {
|
||||
if (tmp.value === "*") {
|
||||
return null;
|
||||
}
|
||||
if (["delete", "in", "instanceof", "new", "typeof", "void"].indexOf(tmp.value) === -1) {
|
||||
unexpected(tmp);
|
||||
}
|
||||
case "name":
|
||||
|
||||
Reference in New Issue
Block a user