Skip to content

Commit b515769

Browse files
committed
wip - moving to : over ->
1 parent 6299ef9 commit b515769

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

src/parser/expression.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,12 @@ pp.parseExprOps = function (noIn, refShorthandDefaultPos) {
239239
pp.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) {
240240
// correct ASI failures.
241241
if (this.hasPlugin("lightscript") && this.isLineBreak()) {
242-
243242
// if it's a newline followed by a unary +/-, bail so it can be parsed separately.
244243
if (this.match(tt.plusMin) && !this.isNextCharWhitespace()) {
245244
return left;
246245
}
247-
// if it's a `|` in a match/case on a newline, assume it's for the "case"
248-
// TODO: consider using indentation to be more precise about this
249-
// TODO: just remove all bitwise operators so this isn't necessary.
250-
if (this.match(tt.bitwiseOR) && this.state.inMatchCaseConsequent) {
246+
// for match/case
247+
if (this.match(tt.bitwiseOR)) {
251248
return left;
252249
}
253250
}

src/plugins/lightscript.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ pp.parseMatch = function () {
573573
}
574574

575575
const matchCase = this.parseMatchCase();
576-
if (matchCase.test && matchCase.test.type === "MatchElse") {
576+
if (matchCase.test.type === "MatchElse") {
577577
hasUsedElse = true;
578578
}
579579
node.cases.push(matchCase);
@@ -586,17 +586,13 @@ pp.parseMatchCase = function () {
586586
const node = this.startNode();
587587

588588
node.test = this.parseMatchCaseTest();
589-
this.expect(tt.comma);
590589

591-
// parse arrow function expression. (TODO: consider allowing NamedArrowExpression)
592-
const oldInMatchCaseConsequent = this.state.inMatchCaseConsequent;
593-
this.state.inMatchCaseConsequent = true;
594-
node.consequent = this.parseMaybeAssign();
595-
this.state.inMatchCaseConsequent = oldInMatchCaseConsequent;
596-
if (node.consequent.type !== "ArrowFunctionExpression") {
597-
this.unexpected(node.consequent.start, tt.arrow);
590+
if (this.eat(tt._with)) {
591+
node.binding = this.parseBindingAtom();
598592
}
599593

594+
node.consequent = this.parseBlock(false);
595+
600596
return this.finishNode(node, "MatchCase");
601597
};
602598

src/tokenizer/state.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ export default class State {
4040

4141
// for lightscript
4242
this.indentLevel = 0;
43-
this.inMatchCaseConsequent =
44-
this.inMatchCaseTest =
45-
false;
43+
this.inMatchCaseTest = false;
4644

4745
this.type = tt.eof;
4846
this.value = null;

0 commit comments

Comments
 (0)