Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/plugins/lightscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,13 @@ pp.parseIf = function (node, isExpression) {
node.test = this.parseParenExpression();

if (isExpression) {
node.consequent = this.match(tt.braceL)
? this.parseBlock(false)
: this.parseWhiteBlock(false, true);
if (this.match(tt.braceL)) {
node.consequent = this.parseBlock(false);
} else if (!this.match(tt.colon)) {
node.consequent = this.parseMaybeAssign();
} else {
node.consequent = this.parseWhiteBlock(false, true);
}
} else {
node.consequent = this.parseStatement(false);
}
Expand Down
151 changes: 151 additions & 0 deletions test/fixtures/es2015/uncategorised/273/expected.lightscript.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
"type": "File",
"start": 0,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 18
}
},
"program": {
"type": "Program",
"start": 0,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 18
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 18
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 18
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "a"
},
"name": "a"
},
"init": {
"type": "ArrayExpression",
"start": 8,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 18
}
},
"elements": [
{
"type": "IfExpression",
"start": 9,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 17
}
},
"test": {
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "x"
},
"name": "x"
},
"consequent": {
"type": "Identifier",
"start": 16,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "x"
},
"name": "x"
},
"alternate": null
}
]
}
}
],
"kind": "var"
}
],
"directives": []
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = if(true) 1
139 changes: 139 additions & 0 deletions test/fixtures/lightscript/if-expression/paren-expr-body/expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"type": "File",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"kind": "const",
"extra": {
"implicit": true
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"id": {
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "x"
},
"name": "x"
},
"init": {
"type": "IfExpression",
"start": 4,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 14
}
},
"test": {
"type": "BooleanLiteral",
"start": 7,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 11
}
},
"value": true
},
"consequent": {
"type": "NumericLiteral",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 14
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
},
"alternate": null
}
}
]
}
],
"directives": []
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
if(true) 1
Loading