diff --git a/src/tokenizer/types.js b/src/tokenizer/types.js index 42be89b8b8..87fe56535b 100644 --- a/src/tokenizer/types.js +++ b/src/tokenizer/types.js @@ -56,7 +56,7 @@ export class BinopTokenType extends TokenType { export const types = { // LightScript tilde: new TokenType("~"), - awaitArrow: new TokenType("<-", { beforeExpr, isAssign }), + awaitArrow: new TokenType("<-", { startsExpr, beforeExpr, isAssign }), elvis: new TokenType("?."), num: new TokenType("num", { startsExpr }), diff --git a/test/fixtures/lightscript/await-arrow/after-bang/actual.js b/test/fixtures/lightscript/await-arrow/after-bang/actual.js new file mode 100644 index 0000000000..cc90f9164d --- /dev/null +++ b/test/fixtures/lightscript/await-arrow/after-bang/actual.js @@ -0,0 +1,2 @@ +f() -/> + console.log! <- x diff --git a/test/fixtures/lightscript/await-arrow/after-bang/expected.json b/test/fixtures/lightscript/await-arrow/after-bang/expected.json new file mode 100644 index 0000000000..a591bed444 --- /dev/null +++ b/test/fixtures/lightscript/await-arrow/after-bang/expected.json @@ -0,0 +1,209 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "sourceType": "script", + "body": [ + { + "type": "NamedArrowDeclaration", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 0, + "end": 1, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "expression": false, + "async": true, + "params": [], + "skinny": true, + "body": { + "type": "BlockStatement", + "start": 4, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 10, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "expression": { + "type": "CallExpression", + "start": 10, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "callee": { + "type": "MemberExpression", + "start": 10, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "object": { + "type": "Identifier", + "start": 10, + "end": 17, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "console" + }, + "name": "console" + }, + "property": { + "type": "Identifier", + "start": 18, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "log" + }, + "name": "log" + }, + "computed": false + }, + "arguments": [ + { + "type": "AwaitExpression", + "start": 23, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "argument": { + "type": "Identifier", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "extra": { + "bang": true + } + } + } + ], + "directives": [], + "extra": { + "curly": false + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/lightscript/await-arrow/arrow-fn-oneline/expected.json b/test/fixtures/lightscript/await-arrow/arrow-fn-oneline/expected.json index a6f30b4f33..e4b72db6c0 100644 --- a/test/fixtures/lightscript/await-arrow/arrow-fn-oneline/expected.json +++ b/test/fixtures/lightscript/await-arrow/arrow-fn-oneline/expected.json @@ -60,76 +60,40 @@ "name": "f" }, "generator": false, - "expression": false, + "expression": true, "async": true, "params": [], "skinny": true, "body": { - "type": "BlockStatement", - "start": 4, + "type": "AwaitExpression", + "start": 8, "end": 12, "loc": { "start": { "line": 1, - "column": 4 + "column": 8 }, "end": { "line": 1, "column": 12 } }, - "body": [ - { - "type": "ExpressionStatement", - "start": 8, - "end": 12, - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 12 - } + "argument": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 }, - "expression": { - "type": "AwaitExpression", - "start": 8, - "end": 12, - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "argument": { - "type": "Identifier", - "start": 11, - "end": 12, - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 12 - }, - "identifierName": "x" - }, - "name": "x" - } - } - } - ], - "directives": [], - "extra": { - "curly": false + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "x" + }, + "name": "x" } } } diff --git a/test/fixtures/lightscript/await-arrow/arrow-fn-safe-oneline/expected.json b/test/fixtures/lightscript/await-arrow/arrow-fn-safe-oneline/expected.json index 9ef0422f90..60b8bb0007 100644 --- a/test/fixtures/lightscript/await-arrow/arrow-fn-safe-oneline/expected.json +++ b/test/fixtures/lightscript/await-arrow/arrow-fn-safe-oneline/expected.json @@ -60,76 +60,40 @@ "name": "f" }, "generator": false, - "expression": false, + "expression": true, "async": true, "params": [], "skinny": true, "body": { - "type": "BlockStatement", - "start": 4, + "type": "SafeAwaitExpression", + "start": 8, "end": 13, "loc": { "start": { "line": 1, - "column": 4 + "column": 8 }, "end": { "line": 1, "column": 13 } }, - "body": [ - { - "type": "ExpressionStatement", - "start": 8, - "end": 13, - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 13 - } + "argument": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 }, - "expression": { - "type": "SafeAwaitExpression", - "start": 8, - "end": 13, - "loc": { - "start": { - "line": 1, - "column": 8 - }, - "end": { - "line": 1, - "column": 13 - } - }, - "argument": { - "type": "Identifier", - "start": 12, - "end": 13, - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 13 - }, - "identifierName": "x" - }, - "name": "x" - } - } - } - ], - "directives": [], - "extra": { - "curly": false + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "x" + }, + "name": "x" } } }