Make let a contextual keyword
This commit is contained in:
@@ -344,7 +344,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
} else {
|
||||
if (
|
||||
this.match(tt._const) ||
|
||||
this.match(tt._let) ||
|
||||
this.isLet() ||
|
||||
((this.isContextual("type") || this.isContextual("interface")) &&
|
||||
!insideModule)
|
||||
) {
|
||||
|
||||
@@ -1190,8 +1190,15 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
if (this.isLineTerminator()) {
|
||||
return;
|
||||
}
|
||||
let starttype = this.state.type;
|
||||
let kind;
|
||||
|
||||
switch (this.state.type) {
|
||||
if (this.isContextual("let")) {
|
||||
starttype = tt._var;
|
||||
kind = "let";
|
||||
}
|
||||
|
||||
switch (starttype) {
|
||||
case tt._function:
|
||||
this.next();
|
||||
return this.parseFunction(nany, /* isStatement */ true);
|
||||
@@ -1210,8 +1217,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
// falls through
|
||||
case tt._var:
|
||||
case tt._let:
|
||||
return this.parseVarStatement(nany, this.state.type);
|
||||
kind = kind || this.state.value;
|
||||
return this.parseVarStatement(nany, kind);
|
||||
case tt.name: {
|
||||
const value = this.state.value;
|
||||
if (value === "global") {
|
||||
|
||||
Reference in New Issue
Block a user