From 93088f68cd3ce22db348ddc479fa4e4586170745 Mon Sep 17 00:00:00 2001 From: "William C. Johnson" Date: Thu, 28 Sep 2017 17:07:19 -0400 Subject: [PATCH] Splat comprehension parsing --- src/parser/expression.js | 21 +- ...Comprehension.js => splatComprehension.js} | 18 +- src/registerPlugins.js | 4 +- src/tokenizer/index.js | 19 ++ test/fixtures/comments/options.json | 2 +- .../comprehension/array/case/actual.js | 1 - .../comprehension/array/for/actual.js | 2 +- .../comprehension/array/for/expected.json | 105 +++++---- .../fixtures/comprehension/array/if/actual.js | 1 + .../array/{case => if}/expected.json | 77 +++--- .../array/kitchen-sink/actual.js | 6 +- .../array/kitchen-sink/expected.json | 216 +++++++++-------- .../comprehension/array/seqexpr-ish/actual.js | 2 +- .../array/seqexpr-ish/expected.json | 85 ++++--- .../comprehension/object/case/actual.js | 1 - .../comprehension/object/case/expected.json | 189 --------------- .../comprehension/object/for/actual.js | 2 +- .../comprehension/object/for/expected.json | 191 ++++++++------- .../comprehension/object/if/actual.js | 1 + .../comprehension/object/if/expected.json | 221 ++++++++++++++++++ test/fixtures/core/options.json | 2 +- .../core/uncategorised/122/options.json | 2 +- .../core/uncategorised/146/options.json | 2 +- .../core/uncategorised/19/options.json | 2 +- .../core/uncategorised/225/options.json | 2 +- .../core/uncategorised/321/options.json | 2 +- .../core/uncategorised/542/options.json | 2 +- test/fixtures/es2015/options.json | 2 +- .../es2015/uncategorised/293/options.json | 2 +- .../es2015/uncategorised/302/options.json | 2 +- test/fixtures/es2017/options.json | 2 +- .../yield-expression-precedence/options.json | 2 +- .../migrated_0013/options.json | 2 +- .../migrated_0008/options.json | 2 +- test/fixtures/esprima/options.json | 2 +- .../migrated_0001/options.json | 2 +- .../for-statement-with-seq/options.json | 2 +- .../subscripts/subscript-illegal/options.json | 2 +- .../for-await-async-context/options.json | 2 +- .../asi-failure-computed/options.json | 2 +- .../object-rest-spread/5/options.json | 2 +- test/fixtures/flow/options.json | 2 +- .../options.json | 2 +- .../malformed-as-pattern/options.json | 2 +- .../object-paren-free/options.json | 2 +- .../expected.whiteblock.json | 136 +++++------ .../object-block-ambiguity/options.json | 1 + test/fixtures/lightscript/options.json | 2 +- .../options.json | 2 +- .../discriminant-expression/options.json | 2 +- .../discriminant/illegal-as/options.json | 2 +- 51 files changed, 756 insertions(+), 603 deletions(-) rename src/plugins/{enhancedComprehension.js => splatComprehension.js} (76%) delete mode 100644 test/fixtures/comprehension/array/case/actual.js create mode 100644 test/fixtures/comprehension/array/if/actual.js rename test/fixtures/comprehension/array/{case => if}/expected.json (65%) delete mode 100644 test/fixtures/comprehension/object/case/actual.js delete mode 100644 test/fixtures/comprehension/object/case/expected.json create mode 100644 test/fixtures/comprehension/object/if/actual.js create mode 100644 test/fixtures/comprehension/object/if/expected.json diff --git a/src/parser/expression.js b/src/parser/expression.js index ecd258f146..1f94a2151e 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -747,7 +747,7 @@ pp.parseExprAtom = function (refShorthandDefaultPos) { if (this.state.inMatchAtom) { this.unexpected(null, "Illegal expression in match atom."); } - if (this.hasPlugin("enhancedComprehension")) { + if (this.hasPlugin("splatComprehension")) { return this.parseComprehensionArray(refShorthandDefaultPos); } node = this.startNode(); @@ -1074,7 +1074,7 @@ pp.parseObj = function (isPattern, refShorthandDefaultPos) { // `for` keyword begins an object comprehension. if ( this.hasPlugin("lightscript") && - !this.hasPlugin("enhancedComprehension") && + !this.hasPlugin("splatComprehension") && this.match(tt._for) ) { // ...however, `{ for: x }` is a legal JS object. @@ -1097,18 +1097,13 @@ pp.parseObj = function (isPattern, refShorthandDefaultPos) { if (this.eat(tt.braceR)) break; } - if ( - this.hasPlugin("enhancedComprehension") && - (this.match(tt._for) || this.match(tt._case)) - ) { - if (this.lookahead().type !== tt.colon) { - if (isPattern) { - this.unexpected(null, "Comprehensions are illegal in patterns."); - } - node.properties.push(this.parseSomeComprehension()); - hasComprehension = true; - continue; + if (this.hasPlugin("splatComprehension") && this.match(tt.splatComprehension)) { + if (isPattern) { + this.unexpected(null, "Comprehensions are illegal in patterns."); } + node.properties.push(this.parseSomeComprehension()); + hasComprehension = true; + continue; } while (this.match(tt.at)) { diff --git a/src/plugins/enhancedComprehension.js b/src/plugins/splatComprehension.js similarity index 76% rename from src/plugins/enhancedComprehension.js rename to src/plugins/splatComprehension.js index 393669c9c9..a7843b56e6 100644 --- a/src/plugins/enhancedComprehension.js +++ b/src/plugins/splatComprehension.js @@ -1,10 +1,12 @@ import Parser from "../parser"; -import { types as tt } from "../tokenizer/types"; +import { types as tt, TokenType } from "../tokenizer/types"; const pp = Parser.prototype; export default function(parser) { - if (parser.__enhancedComprehensionPluginInstalled) return; - parser.__enhancedComprehensionPluginInstalled = true; + if (parser.__splatComprehensionPluginInstalled) return; + parser.__splatComprehensionPluginInstalled = true; + + tt.splatComprehension = new TokenType("...for"); pp.parseComprehensionArray = function(refShorthandDefaultPos) { const node = this.startNode(); @@ -34,10 +36,10 @@ export default function(parser) { if (this.eat(tt.bracketR)) break; } - if (this.match(tt._for)) { + if (this.match(tt.splatComprehension) && this.state.value === "for") { hasComprehension = true; elts.push(this.parseLoopComprehension()); - } else if (this.match(tt._case)) { + } else if (this.match(tt.splatComprehension) && this.state.value === "if") { hasComprehension = true; elts.push(this.parseCaseComprehension()); } else { @@ -64,12 +66,12 @@ export default function(parser) { }; pp.parseSomeComprehension = function() { - if (this.match(tt._for)) { + if (this.match(tt.splatComprehension) && this.state.value === "for") { return this.parseLoopComprehension(); - } else if (this.match(tt._case)) { + } else if (this.match(tt.splatComprehension) && this.state.value === "if") { return this.parseCaseComprehension(); } else { - this.unexpected(null, "Unexpected token, expected `for` or `case`"); + this.unexpected(); } }; } diff --git a/src/registerPlugins.js b/src/registerPlugins.js index 6d49fe19c1..49e48c077c 100644 --- a/src/registerPlugins.js +++ b/src/registerPlugins.js @@ -6,7 +6,7 @@ import tildeCallPlugin from "./plugins/tildeCall"; import safeCallExistentialPlugin from "./plugins/safeCallExistential"; import bangCallPlugin from "./plugins/bangCall"; import significantWhitespacePlugin from "./plugins/significantWhitespace"; -import enhancedComprehensionPlugin from "./plugins/enhancedComprehension"; +import splatComprehensionPlugin from "./plugins/splatComprehension"; import syntacticPlaceholderPlugin from "./plugins/syntacticPlaceholder"; import pipeCallPlugin from "./plugins/pipeCall"; import { matchCoreSyntax, match } from "./plugins/match"; @@ -69,7 +69,7 @@ export default function registerPlugins(plugins, metadata) { dependencies: ["lightscript", "matchCoreSyntax"] }); - registerPlugin("enhancedComprehension", enhancedComprehensionPlugin, { + registerPlugin("splatComprehension", splatComprehensionPlugin, { dependencies: [ "lightscript", // needed for `parseIf` "seqExprRequiresParen" diff --git a/src/tokenizer/index.js b/src/tokenizer/index.js index e0b225360b..8cd5285b8e 100644 --- a/src/tokenizer/index.js +++ b/src/tokenizer/index.js @@ -282,6 +282,25 @@ export default class Tokenizer { const next2 = this.input.charCodeAt(this.state.pos + 2); if (next === 46 && next2 === 46) { // 46 = dot '.' this.state.pos += 3; + // splatComprehension: parse ...for and ...if + if (this.hasPlugin("splatComprehension")) { + const next3 = this.input.charCodeAt(this.state.pos); + const next4 = this.input.charCodeAt(this.state.pos + 1); + const next5 = this.input.charCodeAt(this.state.pos + 2); + // "...if" + if (next3 === 105 && next4 === 102 && !isIdentifierChar(next5)) { + this.state.pos += 2; + return this.finishToken(tt.splatComprehension, "if"); + } else if ( // "...for" + next3 === 102 && + next4 === 111 && + next5 === 114 && + !isIdentifierChar(this.input.charCodeAt(this.state.pos + 3)) + ) { + this.state.pos += 3; + return this.finishToken(tt.splatComprehension, "for"); + } + } return this.finishToken(tt.ellipsis); } else { ++this.state.pos; diff --git a/test/fixtures/comments/options.json b/test/fixtures/comments/options.json index c9ca3f290a..3b240ce0f5 100644 --- a/test/fixtures/comments/options.json +++ b/test/fixtures/comments/options.json @@ -7,7 +7,7 @@ }, "noLsc": { "allPlugins": true, - "excludePlugins": ["lightscript", "match", "enhancedComprehension", "whiteblockOnly"] + "excludePlugins": ["lightscript", "match", "splatComprehension", "whiteblockOnly"] } } } diff --git a/test/fixtures/comprehension/array/case/actual.js b/test/fixtures/comprehension/array/case/actual.js deleted file mode 100644 index 7112438d52..0000000000 --- a/test/fixtures/comprehension/array/case/actual.js +++ /dev/null @@ -1 +0,0 @@ -[case true: 1] diff --git a/test/fixtures/comprehension/array/for/actual.js b/test/fixtures/comprehension/array/for/actual.js index c18be76c3c..8234dfdf85 100644 --- a/test/fixtures/comprehension/array/for/actual.js +++ b/test/fixtures/comprehension/array/for/actual.js @@ -1 +1 @@ -[for idx i in Array(10): i] +[ ...for idx i in Array(10): [i] ] diff --git a/test/fixtures/comprehension/array/for/expected.json b/test/fixtures/comprehension/array/for/expected.json index 933f118a06..40c09d6356 100644 --- a/test/fixtures/comprehension/array/for/expected.json +++ b/test/fixtures/comprehension/array/for/expected.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 27, + "end": 34, "loc": { "start": { "line": 1, @@ -9,13 +9,13 @@ }, "end": { "line": 1, - "column": 27 + "column": 34 } }, "program": { "type": "Program", "start": 0, - "end": 27, + "end": 34, "loc": { "start": { "line": 1, @@ -23,7 +23,7 @@ }, "end": { "line": 1, - "column": 27 + "column": 34 } }, "sourceType": "script", @@ -31,7 +31,7 @@ { "type": "ExpressionStatement", "start": 0, - "end": 27, + "end": 34, "loc": { "start": { "line": 1, @@ -39,13 +39,13 @@ }, "end": { "line": 1, - "column": 27 + "column": 34 } }, "expression": { "type": "ArrayComprehension", "start": 0, - "end": 27, + "end": 34, "loc": { "start": { "line": 1, @@ -53,50 +53,50 @@ }, "end": { "line": 1, - "column": 27 + "column": 34 } }, "elements": [ { "type": "LoopComprehension", - "start": 1, - "end": 26, + "start": 2, + "end": 32, "loc": { "start": { "line": 1, - "column": 1 + "column": 2 }, "end": { "line": 1, - "column": 26 + "column": 32 } }, "loop": { "type": "ForInArrayStatement", - "start": 1, - "end": 26, + "start": 2, + "end": 32, "loc": { "start": { "line": 1, - "column": 1 + "column": 2 }, "end": { "line": 1, - "column": 26 + "column": 32 } }, "idx": { "type": "Identifier", - "start": 9, - "end": 10, + "start": 13, + "end": 14, "loc": { "start": { "line": 1, - "column": 9 + "column": 13 }, "end": { "line": 1, - "column": 10 + "column": 14 }, "identifierName": "i" }, @@ -104,62 +104,79 @@ }, "body": { "type": "ExpressionStatement", - "start": 25, - "end": 26, + "start": 29, + "end": 32, "loc": { "start": { "line": 1, - "column": 25 + "column": 29 }, "end": { "line": 1, - "column": 26 + "column": 32 } }, "expression": { - "type": "Identifier", - "start": 25, - "end": 26, + "type": "ArrayExpression", + "start": 29, + "end": 32, "loc": { "start": { "line": 1, - "column": 25 + "column": 29 }, "end": { "line": 1, - "column": 26 - }, - "identifierName": "i" + "column": 32 + } }, - "name": "i" + "elements": [ + { + "type": "Identifier", + "start": 30, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "i" + }, + "name": "i" + } + ] } }, "array": { "type": "CallExpression", - "start": 14, - "end": 23, + "start": 18, + "end": 27, "loc": { "start": { "line": 1, - "column": 14 + "column": 18 }, "end": { "line": 1, - "column": 23 + "column": 27 } }, "callee": { "type": "Identifier", - "start": 14, - "end": 19, + "start": 18, + "end": 23, "loc": { "start": { "line": 1, - "column": 14 + "column": 18 }, "end": { "line": 1, - "column": 19 + "column": 23 }, "identifierName": "Array" }, @@ -168,16 +185,16 @@ "arguments": [ { "type": "NumericLiteral", - "start": 20, - "end": 22, + "start": 24, + "end": 26, "loc": { "start": { "line": 1, - "column": 20 + "column": 24 }, "end": { "line": 1, - "column": 22 + "column": 26 } }, "extra": { diff --git a/test/fixtures/comprehension/array/if/actual.js b/test/fixtures/comprehension/array/if/actual.js new file mode 100644 index 0000000000..faa6d4f7c2 --- /dev/null +++ b/test/fixtures/comprehension/array/if/actual.js @@ -0,0 +1 @@ +[...if true: [ 1 ] ] diff --git a/test/fixtures/comprehension/array/case/expected.json b/test/fixtures/comprehension/array/if/expected.json similarity index 65% rename from test/fixtures/comprehension/array/case/expected.json rename to test/fixtures/comprehension/array/if/expected.json index 39501348f5..96f78054a2 100644 --- a/test/fixtures/comprehension/array/case/expected.json +++ b/test/fixtures/comprehension/array/if/expected.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 14, + "end": 20, "loc": { "start": { "line": 1, @@ -9,13 +9,13 @@ }, "end": { "line": 1, - "column": 14 + "column": 20 } }, "program": { "type": "Program", "start": 0, - "end": 14, + "end": 20, "loc": { "start": { "line": 1, @@ -23,7 +23,7 @@ }, "end": { "line": 1, - "column": 14 + "column": 20 } }, "sourceType": "script", @@ -31,7 +31,7 @@ { "type": "ExpressionStatement", "start": 0, - "end": 14, + "end": 20, "loc": { "start": { "line": 1, @@ -39,13 +39,13 @@ }, "end": { "line": 1, - "column": 14 + "column": 20 } }, "expression": { "type": "ArrayComprehension", "start": 0, - "end": 14, + "end": 20, "loc": { "start": { "line": 1, @@ -53,14 +53,14 @@ }, "end": { "line": 1, - "column": 14 + "column": 20 } }, "elements": [ { "type": "CaseComprehension", "start": 1, - "end": 13, + "end": 18, "loc": { "start": { "line": 1, @@ -68,13 +68,13 @@ }, "end": { "line": 1, - "column": 13 + "column": 18 } }, "conditional": { "type": "IfStatement", "start": 1, - "end": 13, + "end": 18, "loc": { "start": { "line": 1, @@ -82,58 +82,75 @@ }, "end": { "line": 1, - "column": 13 + "column": 18 } }, "test": { "type": "BooleanLiteral", - "start": 6, - "end": 10, + "start": 7, + "end": 11, "loc": { "start": { "line": 1, - "column": 6 + "column": 7 }, "end": { "line": 1, - "column": 10 + "column": 11 } }, "value": true }, "consequent": { "type": "ExpressionStatement", - "start": 12, - "end": 13, + "start": 13, + "end": 18, "loc": { "start": { "line": 1, - "column": 12 + "column": 13 }, "end": { "line": 1, - "column": 13 + "column": 18 } }, "expression": { - "type": "NumericLiteral", - "start": 12, - "end": 13, + "type": "ArrayExpression", + "start": 13, + "end": 18, "loc": { "start": { "line": 1, - "column": 12 + "column": 13 }, "end": { "line": 1, - "column": 13 + "column": 18 } }, - "extra": { - "rawValue": 1, - "raw": "1" - }, - "value": 1 + "elements": [ + { + "type": "NumericLiteral", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + ] } }, "alternate": null diff --git a/test/fixtures/comprehension/array/kitchen-sink/actual.js b/test/fixtures/comprehension/array/kitchen-sink/actual.js index e2fc12f9b1..216d2053c2 100644 --- a/test/fixtures/comprehension/array/kitchen-sink/actual.js +++ b/test/fixtures/comprehension/array/kitchen-sink/actual.js @@ -1,7 +1,7 @@ [ 1 - case 2: 3 - for elem i in Array(4): 5 + ...if 2: 3 + ...for elem i in Array(4): [ 5 ] 6 - [7, case 8: 9, 10] + [7, ...if 8: [ 9 ], 10] ] diff --git a/test/fixtures/comprehension/array/kitchen-sink/expected.json b/test/fixtures/comprehension/array/kitchen-sink/expected.json index b57dee559a..abfa8a112d 100644 --- a/test/fixtures/comprehension/array/kitchen-sink/expected.json +++ b/test/fixtures/comprehension/array/kitchen-sink/expected.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 72, + "end": 85, "loc": { "start": { "line": 1, @@ -15,7 +15,7 @@ "program": { "type": "Program", "start": 0, - "end": 72, + "end": 85, "loc": { "start": { "line": 1, @@ -31,7 +31,7 @@ { "type": "ExpressionStatement", "start": 0, - "end": 72, + "end": 85, "loc": { "start": { "line": 1, @@ -45,7 +45,7 @@ "expression": { "type": "ArrayComprehension", "start": 0, - "end": 72, + "end": 85, "loc": { "start": { "line": 1, @@ -80,7 +80,7 @@ { "type": "CaseComprehension", "start": 8, - "end": 17, + "end": 18, "loc": { "start": { "line": 3, @@ -88,13 +88,13 @@ }, "end": { "line": 3, - "column": 11 + "column": 12 } }, "conditional": { "type": "IfStatement", "start": 8, - "end": 17, + "end": 18, "loc": { "start": { "line": 3, @@ -102,21 +102,21 @@ }, "end": { "line": 3, - "column": 11 + "column": 12 } }, "test": { "type": "NumericLiteral", - "start": 13, - "end": 14, + "start": 14, + "end": 15, "loc": { "start": { "line": 3, - "column": 7 + "column": 8 }, "end": { "line": 3, - "column": 8 + "column": 9 } }, "extra": { @@ -127,30 +127,30 @@ }, "consequent": { "type": "ExpressionStatement", - "start": 16, - "end": 17, + "start": 17, + "end": 18, "loc": { "start": { "line": 3, - "column": 10 + "column": 11 }, "end": { "line": 3, - "column": 11 + "column": 12 } }, "expression": { "type": "NumericLiteral", - "start": 16, - "end": 17, + "start": 17, + "end": 18, "loc": { "start": { "line": 3, - "column": 10 + "column": 11 }, "end": { "line": 3, - "column": 11 + "column": 12 } }, "extra": { @@ -165,8 +165,8 @@ }, { "type": "LoopComprehension", - "start": 20, - "end": 45, + "start": 21, + "end": 53, "loc": { "start": { "line": 4, @@ -174,13 +174,13 @@ }, "end": { "line": 4, - "column": 27 + "column": 34 } }, "loop": { "type": "ForInArrayStatement", - "start": 20, - "end": 45, + "start": 21, + "end": 53, "loc": { "start": { "line": 4, @@ -188,21 +188,21 @@ }, "end": { "line": 4, - "column": 27 + "column": 34 } }, "elem": { "type": "Identifier", - "start": 29, - "end": 30, + "start": 33, + "end": 34, "loc": { "start": { "line": 4, - "column": 11 + "column": 14 }, "end": { "line": 4, - "column": 12 + "column": 15 }, "identifierName": "i" }, @@ -210,65 +210,82 @@ }, "body": { "type": "ExpressionStatement", - "start": 44, - "end": 45, + "start": 48, + "end": 53, "loc": { "start": { "line": 4, - "column": 26 + "column": 29 }, "end": { "line": 4, - "column": 27 + "column": 34 } }, "expression": { - "type": "NumericLiteral", - "start": 44, - "end": 45, + "type": "ArrayExpression", + "start": 48, + "end": 53, "loc": { "start": { "line": 4, - "column": 26 + "column": 29 }, "end": { "line": 4, - "column": 27 + "column": 34 } }, - "extra": { - "rawValue": 5, - "raw": "5" - }, - "value": 5 + "elements": [ + { + "type": "NumericLiteral", + "start": 50, + "end": 51, + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "extra": { + "rawValue": 5, + "raw": "5" + }, + "value": 5 + } + ] } }, "array": { "type": "CallExpression", - "start": 34, - "end": 42, + "start": 38, + "end": 46, "loc": { "start": { "line": 4, - "column": 16 + "column": 19 }, "end": { "line": 4, - "column": 24 + "column": 27 } }, "callee": { "type": "Identifier", - "start": 34, - "end": 39, + "start": 38, + "end": 43, "loc": { "start": { "line": 4, - "column": 16 + "column": 19 }, "end": { "line": 4, - "column": 21 + "column": 24 }, "identifierName": "Array" }, @@ -277,16 +294,16 @@ "arguments": [ { "type": "NumericLiteral", - "start": 40, - "end": 41, + "start": 44, + "end": 45, "loc": { "start": { "line": 4, - "column": 22 + "column": 25 }, "end": { "line": 4, - "column": 23 + "column": 26 } }, "extra": { @@ -301,8 +318,8 @@ }, { "type": "NumericLiteral", - "start": 48, - "end": 49, + "start": 56, + "end": 57, "loc": { "start": { "line": 5, @@ -321,8 +338,8 @@ }, { "type": "ArrayComprehension", - "start": 52, - "end": 70, + "start": 60, + "end": 83, "loc": { "start": { "line": 6, @@ -330,14 +347,14 @@ }, "end": { "line": 6, - "column": 20 + "column": 25 } }, "elements": [ { "type": "NumericLiteral", - "start": 53, - "end": 54, + "start": 61, + "end": 62, "loc": { "start": { "line": 6, @@ -356,8 +373,8 @@ }, { "type": "CaseComprehension", - "start": 56, - "end": 65, + "start": 64, + "end": 78, "loc": { "start": { "line": 6, @@ -365,13 +382,13 @@ }, "end": { "line": 6, - "column": 15 + "column": 20 } }, "conditional": { "type": "IfStatement", - "start": 56, - "end": 65, + "start": 64, + "end": 78, "loc": { "start": { "line": 6, @@ -379,21 +396,21 @@ }, "end": { "line": 6, - "column": 15 + "column": 20 } }, "test": { "type": "NumericLiteral", - "start": 61, - "end": 62, + "start": 70, + "end": 71, "loc": { "start": { "line": 6, - "column": 11 + "column": 12 }, "end": { "line": 6, - "column": 12 + "column": 13 } }, "extra": { @@ -404,37 +421,54 @@ }, "consequent": { "type": "ExpressionStatement", - "start": 64, - "end": 65, + "start": 73, + "end": 78, "loc": { "start": { "line": 6, - "column": 14 + "column": 15 }, "end": { "line": 6, - "column": 15 + "column": 20 } }, "expression": { - "type": "NumericLiteral", - "start": 64, - "end": 65, + "type": "ArrayExpression", + "start": 73, + "end": 78, "loc": { "start": { "line": 6, - "column": 14 + "column": 15 }, "end": { "line": 6, - "column": 15 + "column": 20 } }, - "extra": { - "rawValue": 9, - "raw": "9" - }, - "value": 9 + "elements": [ + { + "type": "NumericLiteral", + "start": 75, + "end": 76, + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 18 + } + }, + "extra": { + "rawValue": 9, + "raw": "9" + }, + "value": 9 + } + ] } }, "alternate": null @@ -442,16 +476,16 @@ }, { "type": "NumericLiteral", - "start": 67, - "end": 69, + "start": 80, + "end": 82, "loc": { "start": { "line": 6, - "column": 17 + "column": 22 }, "end": { "line": 6, - "column": 19 + "column": 24 } }, "extra": { diff --git a/test/fixtures/comprehension/array/seqexpr-ish/actual.js b/test/fixtures/comprehension/array/seqexpr-ish/actual.js index b8049b3013..0f40b948b0 100644 --- a/test/fixtures/comprehension/array/seqexpr-ish/actual.js +++ b/test/fixtures/comprehension/array/seqexpr-ish/actual.js @@ -1 +1 @@ -[case 1: 2, 3] +[...if 1: [ 2 ], 3] diff --git a/test/fixtures/comprehension/array/seqexpr-ish/expected.json b/test/fixtures/comprehension/array/seqexpr-ish/expected.json index 8cf6485ee8..53970ab692 100644 --- a/test/fixtures/comprehension/array/seqexpr-ish/expected.json +++ b/test/fixtures/comprehension/array/seqexpr-ish/expected.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 14, + "end": 19, "loc": { "start": { "line": 1, @@ -9,13 +9,13 @@ }, "end": { "line": 1, - "column": 14 + "column": 19 } }, "program": { "type": "Program", "start": 0, - "end": 14, + "end": 19, "loc": { "start": { "line": 1, @@ -23,7 +23,7 @@ }, "end": { "line": 1, - "column": 14 + "column": 19 } }, "sourceType": "script", @@ -31,7 +31,7 @@ { "type": "ExpressionStatement", "start": 0, - "end": 14, + "end": 19, "loc": { "start": { "line": 1, @@ -39,13 +39,13 @@ }, "end": { "line": 1, - "column": 14 + "column": 19 } }, "expression": { "type": "ArrayComprehension", "start": 0, - "end": 14, + "end": 19, "loc": { "start": { "line": 1, @@ -53,14 +53,14 @@ }, "end": { "line": 1, - "column": 14 + "column": 19 } }, "elements": [ { "type": "CaseComprehension", "start": 1, - "end": 10, + "end": 15, "loc": { "start": { "line": 1, @@ -68,13 +68,13 @@ }, "end": { "line": 1, - "column": 10 + "column": 15 } }, "conditional": { "type": "IfStatement", "start": 1, - "end": 10, + "end": 15, "loc": { "start": { "line": 1, @@ -82,21 +82,21 @@ }, "end": { "line": 1, - "column": 10 + "column": 15 } }, "test": { "type": "NumericLiteral", - "start": 6, - "end": 7, + "start": 7, + "end": 8, "loc": { "start": { "line": 1, - "column": 6 + "column": 7 }, "end": { "line": 1, - "column": 7 + "column": 8 } }, "extra": { @@ -107,37 +107,54 @@ }, "consequent": { "type": "ExpressionStatement", - "start": 9, - "end": 10, + "start": 10, + "end": 15, "loc": { "start": { "line": 1, - "column": 9 + "column": 10 }, "end": { "line": 1, - "column": 10 + "column": 15 } }, "expression": { - "type": "NumericLiteral", - "start": 9, - "end": 10, + "type": "ArrayExpression", + "start": 10, + "end": 15, "loc": { "start": { "line": 1, - "column": 9 + "column": 10 }, "end": { "line": 1, - "column": 10 + "column": 15 } }, - "extra": { - "rawValue": 2, - "raw": "2" - }, - "value": 2 + "elements": [ + { + "type": "NumericLiteral", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + ] } }, "alternate": null @@ -145,16 +162,16 @@ }, { "type": "NumericLiteral", - "start": 12, - "end": 13, + "start": 17, + "end": 18, "loc": { "start": { "line": 1, - "column": 12 + "column": 17 }, "end": { "line": 1, - "column": 13 + "column": 18 } }, "extra": { diff --git a/test/fixtures/comprehension/object/case/actual.js b/test/fixtures/comprehension/object/case/actual.js deleted file mode 100644 index 4b495215b5..0000000000 --- a/test/fixtures/comprehension/object/case/actual.js +++ /dev/null @@ -1 +0,0 @@ -{case true: ("k", "v")} diff --git a/test/fixtures/comprehension/object/case/expected.json b/test/fixtures/comprehension/object/case/expected.json deleted file mode 100644 index 5c7164870d..0000000000 --- a/test/fixtures/comprehension/object/case/expected.json +++ /dev/null @@ -1,189 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 23, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 23, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, - "sourceType": "script", - "body": [ - { - "type": "ExpressionStatement", - "start": 0, - "end": 23, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, - "expression": { - "type": "ObjectComprehension", - "start": 0, - "end": 23, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 23 - } - }, - "properties": [ - { - "type": "CaseComprehension", - "start": 1, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 22 - } - }, - "conditional": { - "type": "IfStatement", - "start": 1, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 22 - } - }, - "test": { - "type": "BooleanLiteral", - "start": 6, - "end": 10, - "loc": { - "start": { - "line": 1, - "column": 6 - }, - "end": { - "line": 1, - "column": 10 - } - }, - "value": true - }, - "consequent": { - "type": "ExpressionStatement", - "start": 12, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 22 - } - }, - "expression": { - "type": "SequenceExpression", - "start": 13, - "end": 21, - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 21 - } - }, - "expressions": [ - { - "type": "StringLiteral", - "start": 13, - "end": 16, - "loc": { - "start": { - "line": 1, - "column": 13 - }, - "end": { - "line": 1, - "column": 16 - } - }, - "extra": { - "rawValue": "k", - "raw": "\"k\"" - }, - "value": "k" - }, - { - "type": "StringLiteral", - "start": 18, - "end": 21, - "loc": { - "start": { - "line": 1, - "column": 18 - }, - "end": { - "line": 1, - "column": 21 - } - }, - "extra": { - "rawValue": "v", - "raw": "\"v\"" - }, - "value": "v" - } - ], - "extra": { - "parenthesized": true, - "parenStart": 12 - } - } - }, - "alternate": null - } - } - ] - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/test/fixtures/comprehension/object/for/actual.js b/test/fixtures/comprehension/object/for/actual.js index b269cac0f3..6a69b86188 100644 --- a/test/fixtures/comprehension/object/for/actual.js +++ b/test/fixtures/comprehension/object/for/actual.js @@ -1 +1 @@ -{for idx i in Array(10): (i, i)} +{ ...for idx i in Array(10): {[i]: i} } diff --git a/test/fixtures/comprehension/object/for/expected.json b/test/fixtures/comprehension/object/for/expected.json index eee5a83940..47cb9890e1 100644 --- a/test/fixtures/comprehension/object/for/expected.json +++ b/test/fixtures/comprehension/object/for/expected.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 32, + "end": 39, "loc": { "start": { "line": 1, @@ -9,13 +9,13 @@ }, "end": { "line": 1, - "column": 32 + "column": 39 } }, "program": { "type": "Program", "start": 0, - "end": 32, + "end": 39, "loc": { "start": { "line": 1, @@ -23,7 +23,7 @@ }, "end": { "line": 1, - "column": 32 + "column": 39 } }, "sourceType": "script", @@ -31,7 +31,7 @@ { "type": "ExpressionStatement", "start": 0, - "end": 32, + "end": 39, "loc": { "start": { "line": 1, @@ -39,13 +39,13 @@ }, "end": { "line": 1, - "column": 32 + "column": 39 } }, "expression": { "type": "ObjectComprehension", "start": 0, - "end": 32, + "end": 39, "loc": { "start": { "line": 1, @@ -53,105 +53,88 @@ }, "end": { "line": 1, - "column": 32 + "column": 39 } }, "properties": [ { "type": "LoopComprehension", - "start": 1, - "end": 31, + "start": 2, + "end": 37, "loc": { "start": { "line": 1, - "column": 1 + "column": 2 }, "end": { "line": 1, - "column": 31 + "column": 37 } }, "loop": { "type": "ForInArrayStatement", - "start": 1, - "end": 31, + "start": 2, + "end": 37, "loc": { "start": { "line": 1, - "column": 1 + "column": 2 }, "end": { "line": 1, - "column": 31 + "column": 37 } }, "idx": { "type": "Identifier", - "start": 9, - "end": 10, + "start": 13, + "end": 14, "loc": { "start": { "line": 1, - "column": 9 + "column": 13 }, "end": { "line": 1, - "column": 10 + "column": 14 }, "identifierName": "i" }, "name": "i" }, "body": { - "type": "ExpressionStatement", - "start": 25, - "end": 31, + "type": "BlockStatement", + "start": 27, + "end": 37, "loc": { "start": { "line": 1, - "column": 25 + "column": 27 }, "end": { "line": 1, - "column": 31 + "column": 37 } }, - "expression": { - "type": "SequenceExpression", - "start": 26, - "end": 30, - "loc": { - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 1, - "column": 30 - } - }, - "expressions": [ - { - "type": "Identifier", - "start": 26, - "end": 27, - "loc": { - "start": { - "line": 1, - "column": 26 - }, - "end": { - "line": 1, - "column": 27 - }, - "identifierName": "i" + "body": [ + { + "type": "ExpressionStatement", + "start": 29, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 29 }, - "name": "i" + "end": { + "line": 1, + "column": 37 + } }, - { - "type": "Identifier", + "expression": { + "type": "ObjectExpression", "start": 29, - "end": 30, + "end": 37, "loc": { "start": { "line": 1, @@ -159,45 +142,97 @@ }, "end": { "line": 1, - "column": 30 - }, - "identifierName": "i" + "column": 37 + } }, - "name": "i" + "properties": [ + { + "type": "ObjectProperty", + "start": 30, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "method": false, + "shorthand": false, + "computed": true, + "key": { + "type": "Identifier", + "start": 31, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "i" + }, + "name": "i" + }, + "value": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + }, + "identifierName": "i" + }, + "name": "i" + } + } + ] } - ], - "extra": { - "parenthesized": true, - "parenStart": 25 } + ], + "directives": [], + "extra": { + "curly": false } }, "array": { "type": "CallExpression", - "start": 14, - "end": 23, + "start": 18, + "end": 27, "loc": { "start": { "line": 1, - "column": 14 + "column": 18 }, "end": { "line": 1, - "column": 23 + "column": 27 } }, "callee": { "type": "Identifier", - "start": 14, - "end": 19, + "start": 18, + "end": 23, "loc": { "start": { "line": 1, - "column": 14 + "column": 18 }, "end": { "line": 1, - "column": 19 + "column": 23 }, "identifierName": "Array" }, @@ -206,16 +241,16 @@ "arguments": [ { "type": "NumericLiteral", - "start": 20, - "end": 22, + "start": 24, + "end": 26, "loc": { "start": { "line": 1, - "column": 20 + "column": 24 }, "end": { "line": 1, - "column": 22 + "column": 26 } }, "extra": { diff --git a/test/fixtures/comprehension/object/if/actual.js b/test/fixtures/comprehension/object/if/actual.js new file mode 100644 index 0000000000..3c70edc431 --- /dev/null +++ b/test/fixtures/comprehension/object/if/actual.js @@ -0,0 +1 @@ +{ ...if true: {k: "v"} } diff --git a/test/fixtures/comprehension/object/if/expected.json b/test/fixtures/comprehension/object/if/expected.json new file mode 100644 index 0000000000..c66a69eb71 --- /dev/null +++ b/test/fixtures/comprehension/object/if/expected.json @@ -0,0 +1,221 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expression": { + "type": "ObjectComprehension", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "properties": [ + { + "type": "CaseComprehension", + "start": 2, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "conditional": { + "type": "IfStatement", + "start": 2, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "test": { + "type": "BooleanLiteral", + "start": 8, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "value": true + }, + "consequent": { + "type": "BlockStatement", + "start": 12, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 14, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 14, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "k" + }, + "name": "k" + }, + "value": { + "type": "StringLiteral", + "start": 18, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "extra": { + "rawValue": "v", + "raw": "\"v\"" + }, + "value": "v" + } + } + ] + } + } + ], + "directives": [], + "extra": { + "curly": false + } + }, + "alternate": null + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/core/options.json b/test/fixtures/core/options.json index 7c856c033e..941a40e7a2 100644 --- a/test/fixtures/core/options.json +++ b/test/fixtures/core/options.json @@ -8,7 +8,7 @@ }, "noLsc": { "allPlugins": true, - "excludePlugins": ["lightscript", "match", "enhancedComprehension", "whiteblockOnly"] + "excludePlugins": ["lightscript", "match", "splatComprehension", "whiteblockOnly"] } } } diff --git a/test/fixtures/core/uncategorised/122/options.json b/test/fixtures/core/uncategorised/122/options.json index f0ef06db61..340c5ecc67 100644 --- a/test/fixtures/core/uncategorised/122/options.json +++ b/test/fixtures/core/uncategorised/122/options.json @@ -8,7 +8,7 @@ }, "noSeqExprParens": { "allPlugins": true, - "excludePlugins": ["seqExprRequiresParen", "enhancedComprehension", "bangCall"] + "excludePlugins": ["seqExprRequiresParen", "splatComprehension", "bangCall"] } } } diff --git a/test/fixtures/core/uncategorised/146/options.json b/test/fixtures/core/uncategorised/146/options.json index 98c07bea05..e507d5e4d8 100644 --- a/test/fixtures/core/uncategorised/146/options.json +++ b/test/fixtures/core/uncategorised/146/options.json @@ -9,7 +9,7 @@ "noTildeCalls": { "allPlugins": true, "excludePlugins": [ - "lightscript", "match", "enhancedComprehension", + "lightscript", "match", "splatComprehension", "whiteblockOnly", "tildeCallExpression" ], "expected": "expected.json" diff --git a/test/fixtures/core/uncategorised/19/options.json b/test/fixtures/core/uncategorised/19/options.json index d35e085559..4a49505418 100644 --- a/test/fixtures/core/uncategorised/19/options.json +++ b/test/fixtures/core/uncategorised/19/options.json @@ -1,7 +1,7 @@ { "alternatives": { "noLsc": { - "excludePlugins": ["significantWhitespace", "bangCall", "enforceSubscriptIndentation", "lightscript", "match", "enhancedComprehension", "whiteblockOnly"] + "excludePlugins": ["significantWhitespace", "bangCall", "enforceSubscriptIndentation", "lightscript", "match", "splatComprehension", "whiteblockOnly"] } } } diff --git a/test/fixtures/core/uncategorised/225/options.json b/test/fixtures/core/uncategorised/225/options.json index ab9de5ae34..0b2fc2313d 100644 --- a/test/fixtures/core/uncategorised/225/options.json +++ b/test/fixtures/core/uncategorised/225/options.json @@ -8,7 +8,7 @@ }, "noSeqExprParens": { "allPlugins": true, - "excludePlugins": ["seqExprRequiresParen", "enhancedComprehension", "bangCall"] + "excludePlugins": ["seqExprRequiresParen", "splatComprehension", "bangCall"] } } } diff --git a/test/fixtures/core/uncategorised/321/options.json b/test/fixtures/core/uncategorised/321/options.json index 3608b87a41..48635f362f 100644 --- a/test/fixtures/core/uncategorised/321/options.json +++ b/test/fixtures/core/uncategorised/321/options.json @@ -1,7 +1,7 @@ { "alternatives": { "noLsc": { - "excludePlugins": ["significantWhitespace", "bangCall", "enforceSubscriptIndentation", "enhancedComprehension", "whiteblockOnly"] + "excludePlugins": ["significantWhitespace", "bangCall", "enforceSubscriptIndentation", "splatComprehension", "whiteblockOnly"] } } } diff --git a/test/fixtures/core/uncategorised/542/options.json b/test/fixtures/core/uncategorised/542/options.json index 3d303ebc6c..c410a58884 100644 --- a/test/fixtures/core/uncategorised/542/options.json +++ b/test/fixtures/core/uncategorised/542/options.json @@ -1,7 +1,7 @@ { "alternatives": { "noLsc": { - "excludePlugins": ["bangCall", "enforceSubscriptIndentation", "significantWhitespace", "enhancedComprehension", "whiteblockOnly"] + "excludePlugins": ["bangCall", "enforceSubscriptIndentation", "significantWhitespace", "splatComprehension", "whiteblockOnly"] } } } diff --git a/test/fixtures/es2015/options.json b/test/fixtures/es2015/options.json index 7c856c033e..941a40e7a2 100644 --- a/test/fixtures/es2015/options.json +++ b/test/fixtures/es2015/options.json @@ -8,7 +8,7 @@ }, "noLsc": { "allPlugins": true, - "excludePlugins": ["lightscript", "match", "enhancedComprehension", "whiteblockOnly"] + "excludePlugins": ["lightscript", "match", "splatComprehension", "whiteblockOnly"] } } } diff --git a/test/fixtures/es2015/uncategorised/293/options.json b/test/fixtures/es2015/uncategorised/293/options.json index 09bb982b62..0bdccf5b61 100644 --- a/test/fixtures/es2015/uncategorised/293/options.json +++ b/test/fixtures/es2015/uncategorised/293/options.json @@ -8,7 +8,7 @@ }, "noSeqExprParens": { "allPlugins": true, - "excludePlugins": ["seqExprRequiresParen", "enhancedComprehension", "bangCall"], + "excludePlugins": ["seqExprRequiresParen", "splatComprehension", "bangCall"], "throws": "Unexpected token (1:6)" } } diff --git a/test/fixtures/es2015/uncategorised/302/options.json b/test/fixtures/es2015/uncategorised/302/options.json index 0fb8bb97c1..ac6ad65648 100644 --- a/test/fixtures/es2015/uncategorised/302/options.json +++ b/test/fixtures/es2015/uncategorised/302/options.json @@ -8,7 +8,7 @@ }, "noSeqExprParens": { "allPlugins": true, - "excludePlugins": ["seqExprRequiresParen", "enhancedComprehension", "bangCall"] + "excludePlugins": ["seqExprRequiresParen", "splatComprehension", "bangCall"] } } } diff --git a/test/fixtures/es2017/options.json b/test/fixtures/es2017/options.json index 7c856c033e..941a40e7a2 100644 --- a/test/fixtures/es2017/options.json +++ b/test/fixtures/es2017/options.json @@ -8,7 +8,7 @@ }, "noLsc": { "allPlugins": true, - "excludePlugins": ["lightscript", "match", "enhancedComprehension", "whiteblockOnly"] + "excludePlugins": ["lightscript", "match", "splatComprehension", "whiteblockOnly"] } } } diff --git a/test/fixtures/esprima/es2015-yield/yield-expression-precedence/options.json b/test/fixtures/esprima/es2015-yield/yield-expression-precedence/options.json index 391b97cdb2..4a65bfda76 100644 --- a/test/fixtures/esprima/es2015-yield/yield-expression-precedence/options.json +++ b/test/fixtures/esprima/es2015-yield/yield-expression-precedence/options.json @@ -8,7 +8,7 @@ }, "noSeqExprParens": { "allPlugins": true, - "excludePlugins": ["seqExprRequiresParen", "enhancedComprehension", "bangCall", "whiteblockOnly"] + "excludePlugins": ["seqExprRequiresParen", "splatComprehension", "bangCall", "whiteblockOnly"] } } } diff --git a/test/fixtures/esprima/expression-left-hand-side/migrated_0013/options.json b/test/fixtures/esprima/expression-left-hand-side/migrated_0013/options.json index f0ef06db61..340c5ecc67 100644 --- a/test/fixtures/esprima/expression-left-hand-side/migrated_0013/options.json +++ b/test/fixtures/esprima/expression-left-hand-side/migrated_0013/options.json @@ -8,7 +8,7 @@ }, "noSeqExprParens": { "allPlugins": true, - "excludePlugins": ["seqExprRequiresParen", "enhancedComprehension", "bangCall"] + "excludePlugins": ["seqExprRequiresParen", "splatComprehension", "bangCall"] } } } diff --git a/test/fixtures/esprima/expression-unary/migrated_0008/options.json b/test/fixtures/esprima/expression-unary/migrated_0008/options.json index 98c07bea05..e507d5e4d8 100644 --- a/test/fixtures/esprima/expression-unary/migrated_0008/options.json +++ b/test/fixtures/esprima/expression-unary/migrated_0008/options.json @@ -9,7 +9,7 @@ "noTildeCalls": { "allPlugins": true, "excludePlugins": [ - "lightscript", "match", "enhancedComprehension", + "lightscript", "match", "splatComprehension", "whiteblockOnly", "tildeCallExpression" ], "expected": "expected.json" diff --git a/test/fixtures/esprima/options.json b/test/fixtures/esprima/options.json index 7c856c033e..941a40e7a2 100644 --- a/test/fixtures/esprima/options.json +++ b/test/fixtures/esprima/options.json @@ -8,7 +8,7 @@ }, "noLsc": { "allPlugins": true, - "excludePlugins": ["lightscript", "match", "enhancedComprehension", "whiteblockOnly"] + "excludePlugins": ["lightscript", "match", "splatComprehension", "whiteblockOnly"] } } } diff --git a/test/fixtures/esprima/statement-expression/migrated_0001/options.json b/test/fixtures/esprima/statement-expression/migrated_0001/options.json index ab9de5ae34..0b2fc2313d 100644 --- a/test/fixtures/esprima/statement-expression/migrated_0001/options.json +++ b/test/fixtures/esprima/statement-expression/migrated_0001/options.json @@ -8,7 +8,7 @@ }, "noSeqExprParens": { "allPlugins": true, - "excludePlugins": ["seqExprRequiresParen", "enhancedComprehension", "bangCall"] + "excludePlugins": ["seqExprRequiresParen", "splatComprehension", "bangCall"] } } } diff --git a/test/fixtures/esprima/statement-iteration/for-statement-with-seq/options.json b/test/fixtures/esprima/statement-iteration/for-statement-with-seq/options.json index da37b7305b..2ebf593f08 100644 --- a/test/fixtures/esprima/statement-iteration/for-statement-with-seq/options.json +++ b/test/fixtures/esprima/statement-iteration/for-statement-with-seq/options.json @@ -8,7 +8,7 @@ }, "noSeqExprParens": { "allPlugins": true, - "excludePlugins": ["seqExprRequiresParen", "enhancedComprehension", "bangCall"] + "excludePlugins": ["seqExprRequiresParen", "splatComprehension", "bangCall"] } } } diff --git a/test/fixtures/existential-expression/subscripts/subscript-illegal/options.json b/test/fixtures/existential-expression/subscripts/subscript-illegal/options.json index 34325e3f1b..274d9eff9d 100644 --- a/test/fixtures/existential-expression/subscripts/subscript-illegal/options.json +++ b/test/fixtures/existential-expression/subscripts/subscript-illegal/options.json @@ -1,4 +1,4 @@ { - "excludePlugins": ["lightscript", "bangCall", "enforceSubscriptIndentation", "match", "enhancedComprehension", "whiteblockOnly"], + "excludePlugins": ["lightscript", "bangCall", "enforceSubscriptIndentation", "match", "splatComprehension", "whiteblockOnly"], "throws": "Unexpected token, expected ; (1:2)" } diff --git a/test/fixtures/experimental/async-generators/for-await-async-context/options.json b/test/fixtures/experimental/async-generators/for-await-async-context/options.json index 47f02d05be..3227688dcd 100644 --- a/test/fixtures/experimental/async-generators/for-await-async-context/options.json +++ b/test/fixtures/experimental/async-generators/for-await-async-context/options.json @@ -6,7 +6,7 @@ }, "noLsc": { "allPlugins": true, - "excludePlugins": ["lightscript", "match", "enhancedComprehension", "whiteblockOnly"] + "excludePlugins": ["lightscript", "match", "splatComprehension", "whiteblockOnly"] } } } diff --git a/test/fixtures/experimental/class-properties/asi-failure-computed/options.json b/test/fixtures/experimental/class-properties/asi-failure-computed/options.json index c06f2f3766..15ebb7db7c 100644 --- a/test/fixtures/experimental/class-properties/asi-failure-computed/options.json +++ b/test/fixtures/experimental/class-properties/asi-failure-computed/options.json @@ -6,7 +6,7 @@ }, "noLsc": { "allPlugins": true, - "excludePlugins": ["lightscript", "match", "enhancedComprehension", "whiteblockOnly"] + "excludePlugins": ["lightscript", "match", "splatComprehension", "whiteblockOnly"] } }, "plugins": ["classProperties"] diff --git a/test/fixtures/experimental/object-rest-spread/5/options.json b/test/fixtures/experimental/object-rest-spread/5/options.json index 968c355120..38f17b6d33 100644 --- a/test/fixtures/experimental/object-rest-spread/5/options.json +++ b/test/fixtures/experimental/object-rest-spread/5/options.json @@ -5,7 +5,7 @@ }, "noLsc": { "allPlugins": true, - "excludePlugins": ["lightscript", "match", "enhancedComprehension", "whiteblockOnly"] + "excludePlugins": ["lightscript", "match", "splatComprehension", "whiteblockOnly"] } } } diff --git a/test/fixtures/flow/options.json b/test/fixtures/flow/options.json index 3b7e170016..ed98b230f5 100644 --- a/test/fixtures/flow/options.json +++ b/test/fixtures/flow/options.json @@ -10,7 +10,7 @@ }, "noLsc": { "allPlugins": true, - "excludePlugins": ["lightscript", "match", "enhancedComprehension", "whiteblockOnly"] + "excludePlugins": ["lightscript", "match", "splatComprehension", "whiteblockOnly"] } } } diff --git a/test/fixtures/lightscript/auto-const/not-newline-object-malformed-unfortunate/options.json b/test/fixtures/lightscript/auto-const/not-newline-object-malformed-unfortunate/options.json index 82112095f4..886143b65d 100644 --- a/test/fixtures/lightscript/auto-const/not-newline-object-malformed-unfortunate/options.json +++ b/test/fixtures/lightscript/auto-const/not-newline-object-malformed-unfortunate/options.json @@ -5,7 +5,7 @@ }, "noSeqExprParens": { "allPlugins": true, - "excludePlugins": ["existentialExpression", "safeCallExpression", "enhancedComprehension", "seqExprRequiresParen", "bangCall", "whiteblockOnly"], + "excludePlugins": ["existentialExpression", "safeCallExpression", "splatComprehension", "seqExprRequiresParen", "bangCall", "whiteblockOnly"], "throws": "Unexpected token (1:10)" }, "whiteblock": { diff --git a/test/fixtures/lightscript/comprehension/malformed-as-pattern/options.json b/test/fixtures/lightscript/comprehension/malformed-as-pattern/options.json index 29a4fe09e9..6f7dcfc72a 100644 --- a/test/fixtures/lightscript/comprehension/malformed-as-pattern/options.json +++ b/test/fixtures/lightscript/comprehension/malformed-as-pattern/options.json @@ -5,7 +5,7 @@ }, "noSeqExprParens": { "allPlugins": true, - "excludePlugins": ["existentialExpression", "safeCallExpression", "enhancedComprehension", "seqExprRequiresParen", "bangCall"], + "excludePlugins": ["existentialExpression", "safeCallExpression", "splatComprehension", "seqExprRequiresParen", "bangCall"], "throws": "Binding invalid left-hand side in variable declaration (1:6)" } } diff --git a/test/fixtures/lightscript/comprehension/object-paren-free/options.json b/test/fixtures/lightscript/comprehension/object-paren-free/options.json index 0ee1da4d10..22fb4f261c 100644 --- a/test/fixtures/lightscript/comprehension/object-paren-free/options.json +++ b/test/fixtures/lightscript/comprehension/object-paren-free/options.json @@ -5,7 +5,7 @@ }, "noSeqExprParens": { "allPlugins": true, - "excludePlugins": ["existentialExpression", "safeCallExpression", "enhancedComprehension", "seqExprRequiresParen", "bangCall"] + "excludePlugins": ["existentialExpression", "safeCallExpression", "splatComprehension", "seqExprRequiresParen", "bangCall"] } } } diff --git a/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.whiteblock.json b/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.whiteblock.json index c3da62b2cd..814c1eb48e 100644 --- a/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.whiteblock.json +++ b/test/fixtures/lightscript/object-block-ambiguity/object-comprehension/expected.whiteblock.json @@ -101,104 +101,88 @@ "column": 1 } }, - "properties": [ - { - "type": "LoopComprehension", - "start": 13, + "properties": [], + "loop": { + "type": "ForInArrayStatement", + "start": 13, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "elem": { + "type": "Identifier", + "start": 22, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "e" + }, + "name": "e" + }, + "body": { + "type": "ExpressionStatement", + "start": 32, "end": 33, "loc": { "start": { "line": 2, - "column": 2 + "column": 21 }, "end": { "line": 2, "column": 22 } }, - "loop": { - "type": "ForInArrayStatement", - "start": 13, + "expression": { + "type": "Identifier", + "start": 32, "end": 33, "loc": { "start": { "line": 2, - "column": 2 + "column": 21 }, "end": { "line": 2, "column": 22 - } - }, - "elem": { - "type": "Identifier", - "start": 22, - "end": 23, - "loc": { - "start": { - "line": 2, - "column": 11 - }, - "end": { - "line": 2, - "column": 12 - }, - "identifierName": "e" }, - "name": "e" + "identifierName": "e" }, - "body": { - "type": "ExpressionStatement", - "start": 32, - "end": 33, - "loc": { - "start": { - "line": 2, - "column": 21 - }, - "end": { - "line": 2, - "column": 22 - } - }, - "expression": { - "type": "Identifier", - "start": 32, - "end": 33, - "loc": { - "start": { - "line": 2, - "column": 21 - }, - "end": { - "line": 2, - "column": 22 - }, - "identifierName": "e" - }, - "name": "e" - } - }, - "array": { - "type": "Identifier", - "start": 27, - "end": 30, - "loc": { - "start": { - "line": 2, - "column": 16 - }, - "end": { - "line": 2, - "column": 19 - }, - "identifierName": "arr" - }, - "name": "arr" - } + "name": "e" } + }, + "array": { + "type": "Identifier", + "start": 27, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "arr" + }, + "name": "arr" } - ] + } } } ], diff --git a/test/fixtures/lightscript/object-block-ambiguity/options.json b/test/fixtures/lightscript/object-block-ambiguity/options.json index 789ef9baa7..441a3fef35 100644 --- a/test/fixtures/lightscript/object-block-ambiguity/options.json +++ b/test/fixtures/lightscript/object-block-ambiguity/options.json @@ -2,6 +2,7 @@ "alternatives": { "whiteblock": { "allPlugins": true, + "excludePlugins": ["splatComprehension"], "expected": "expected.whiteblock.json" } } diff --git a/test/fixtures/lightscript/options.json b/test/fixtures/lightscript/options.json index 3cdb97720d..a8bb0d5cb5 100644 --- a/test/fixtures/lightscript/options.json +++ b/test/fixtures/lightscript/options.json @@ -3,7 +3,7 @@ "alternatives": { "all": { "allPlugins": true, - "excludePlugins": ["existentialExpression", "safeCallExpression", "enhancedComprehension", "bangCall", "flippedImports", "whiteblockOnly"] + "excludePlugins": ["existentialExpression", "safeCallExpression", "splatComprehension", "bangCall", "flippedImports", "whiteblockOnly"] } } } diff --git a/test/fixtures/lightscript/whitespace/no-enforced-indentation-tilde/options.json b/test/fixtures/lightscript/whitespace/no-enforced-indentation-tilde/options.json index c804431ad7..5c737ca792 100644 --- a/test/fixtures/lightscript/whitespace/no-enforced-indentation-tilde/options.json +++ b/test/fixtures/lightscript/whitespace/no-enforced-indentation-tilde/options.json @@ -5,7 +5,7 @@ }, "noEnforcedSubscriptIndentation": { "allPlugins": true, - "excludePlugins": ["existentialExpression", "safeCallExpression", "enhancedComprehension", "bangCall", "flippedImports", "enforceSubscriptIndentation"] + "excludePlugins": ["existentialExpression", "safeCallExpression", "splatComprehension", "bangCall", "flippedImports", "enforceSubscriptIndentation"] } } } diff --git a/test/fixtures/match/discriminant/discriminant-expression/options.json b/test/fixtures/match/discriminant/discriminant-expression/options.json index ba287f93a5..602c62c617 100644 --- a/test/fixtures/match/discriminant/discriminant-expression/options.json +++ b/test/fixtures/match/discriminant/discriminant-expression/options.json @@ -5,7 +5,7 @@ }, "noSeqExprParens": { "allPlugins": true, - "excludePlugins": ["existentialExpression", "safeCallExpression", "enhancedComprehension", "seqExprRequiresParen", "bangCall"] + "excludePlugins": ["existentialExpression", "safeCallExpression", "splatComprehension", "seqExprRequiresParen", "bangCall"] } } } diff --git a/test/fixtures/match/discriminant/illegal-as/options.json b/test/fixtures/match/discriminant/illegal-as/options.json index 8f52261f34..2f651758c8 100644 --- a/test/fixtures/match/discriminant/illegal-as/options.json +++ b/test/fixtures/match/discriminant/illegal-as/options.json @@ -5,7 +5,7 @@ }, "noSeqExprParens": { "allPlugins": true, - "excludePlugins": ["existentialExpression", "safeCallExpression", "enhancedComprehension", "seqExprRequiresParen", "bangCall"], + "excludePlugins": ["existentialExpression", "safeCallExpression", "splatComprehension", "seqExprRequiresParen", "bangCall"], "throws": "Unexpected token, expected { (1:17)" } }