Refactor await/yield production parameter tracking (#10956)
* test: add test fixtures * refactor: track AWAIT and YIELD in separate handler * fix flow errors * add flow type annotation to production-parameter * address review comments * refactor: track [Return] parameter
This commit is contained in:
@@ -12,13 +12,13 @@ import { types as tc } from "../tokenizer/context";
|
||||
import * as charCodes from "charcodes";
|
||||
import { isIteratorStart } from "../util/identifier";
|
||||
import {
|
||||
functionFlags,
|
||||
type BindingTypes,
|
||||
BIND_NONE,
|
||||
BIND_LEXICAL,
|
||||
BIND_VAR,
|
||||
BIND_FUNCTION,
|
||||
SCOPE_ARROW,
|
||||
SCOPE_FUNCTION,
|
||||
SCOPE_OTHER,
|
||||
} from "../util/scopeflags";
|
||||
import type { ExpressionErrors } from "../parser/util";
|
||||
@@ -1889,7 +1889,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node.extra?.trailingComma,
|
||||
);
|
||||
// Enter scope, as checkParams defines bindings
|
||||
this.scope.enter(functionFlags(false, false) | SCOPE_ARROW);
|
||||
this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
|
||||
// Use super's method to force the parameters to be checked
|
||||
super.checkParams(node, false, true);
|
||||
this.scope.exit();
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
import TypeScriptScopeHandler from "./scope";
|
||||
import * as charCodes from "charcodes";
|
||||
import type { ExpressionErrors } from "../../parser/util";
|
||||
import { PARAM } from "../../util/production-parameter";
|
||||
|
||||
type TsModifier =
|
||||
| "readonly"
|
||||
@@ -1265,7 +1266,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
node.body = inner;
|
||||
} else {
|
||||
this.scope.enter(SCOPE_TS_MODULE);
|
||||
this.prodParam.enter(PARAM);
|
||||
node.body = this.tsParseModuleBlock();
|
||||
this.prodParam.exit();
|
||||
this.scope.exit();
|
||||
}
|
||||
return this.finishNode(node, "TSModuleDeclaration");
|
||||
@@ -1284,7 +1287,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
if (this.match(tt.braceL)) {
|
||||
this.scope.enter(SCOPE_TS_MODULE);
|
||||
this.prodParam.enter(PARAM);
|
||||
node.body = this.tsParseModuleBlock();
|
||||
this.prodParam.exit();
|
||||
this.scope.exit();
|
||||
} else {
|
||||
this.semicolon();
|
||||
@@ -1439,11 +1444,13 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
// Would like to use tsParseAmbientExternalModuleDeclaration here, but already ran past "global".
|
||||
if (this.match(tt.braceL)) {
|
||||
this.scope.enter(SCOPE_TS_MODULE);
|
||||
this.prodParam.enter(PARAM);
|
||||
const mod: N.TsModuleDeclaration = node;
|
||||
mod.global = true;
|
||||
mod.id = expr;
|
||||
mod.body = this.tsParseModuleBlock();
|
||||
this.scope.exit();
|
||||
this.prodParam.exit();
|
||||
return this.finishNode(mod, "TSModuleDeclaration");
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user