fix corner cases with static modifier (#5599)

This commit is contained in:
Alex Lam S.L
2022-08-04 19:48:21 +01:00
committed by GitHub
parent 884842cd6c
commit 41b65af6e2
2 changed files with 91 additions and 3 deletions

View File

@@ -1056,13 +1056,13 @@ function parse($TEXT, options) {
return stat;
}
function has_modifier(name) {
function has_modifier(name, no_nlb) {
if (!is("name", name)) return;
var token = peek();
if (!token) return;
if (is_token(token, "operator", "=")) return;
if (token.type == "punc" && /^[(;}]$/.test(token.value)) return;
if (has_newline_before(token)) return;
if (no_nlb && has_newline_before(token)) return;
return next();
}
@@ -1092,7 +1092,7 @@ function parse($TEXT, options) {
}
var start = S.token;
var fixed = !!has_modifier("static");
var async = has_modifier("async");
var async = has_modifier("async", true);
if (is("operator", "*")) {
next();
var internal = is("name") && /^#/.test(S.token.value);