add lineBreak test to tt.name.updateContext - fixes #2591
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
// See https://github.com/mozilla/sweet.js/wiki/design
|
||||
|
||||
import { types as tt } from "./types";
|
||||
import { lineBreak } from "../util/whitespace";
|
||||
|
||||
export class TokContext {
|
||||
constructor(
|
||||
@@ -54,6 +55,14 @@ tt.parenR.updateContext = tt.braceR.updateContext = function () {
|
||||
}
|
||||
};
|
||||
|
||||
tt.name.updateContext = function (prevType) {
|
||||
if (prevType === tt._let || prevType === tt._const || prevType === tt._var) {
|
||||
if (lineBreak.test(this.input.slice(this.state.end))) {
|
||||
this.state.exprAllowed = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
tt.braceL.updateContext = function (prevType) {
|
||||
this.state.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr);
|
||||
this.state.exprAllowed = true;
|
||||
|
||||
Reference in New Issue
Block a user