fix corner cases in merge_vars & with exports (#4762)

fixes #4761
This commit is contained in:
Alex Lam S.L
2021-03-11 01:16:16 +00:00
committed by GitHub
parent b4944a31a4
commit 862b1b77b5
4 changed files with 42 additions and 11 deletions

View File

@@ -1504,14 +1504,14 @@ function parse($TEXT, options) {
}
function export_default_decl() {
switch (S.token.value) {
case "async":
if (is("name", "async")) {
if (!is_token(peek(), "keyword", "function")) return;
next();
next();
if (!is("operator", "*")) return maybe_named(AST_AsyncDefun, function_(AST_AsyncFunction));
next();
return maybe_named(AST_AsyncGeneratorDefun, function_(AST_AsyncGeneratorFunction));
} else if (is("keyword")) switch (S.token.value) {
case "class":
next();
return maybe_named(AST_DefClass, class_(AST_ClassExpression));
@@ -1524,13 +1524,13 @@ function parse($TEXT, options) {
}
var export_decl = embed_tokens(function() {
switch (S.token.value) {
case "async":
if (is("name", "async")) {
next();
expect_token("keyword", "function");
if (!is("operator", "*")) return function_(AST_AsyncDefun);
next();
return function_(AST_AsyncGeneratorDefun);
} else if (is("keyword")) switch (S.token.value) {
case "class":
next();
return class_(AST_DefClass);