sweet-core
sweet-core copied to clipboard
breaks code that uses async or await
I'm running the master branch, at commit https://github.com/sweet-js/sweet.js/commit/62a63cd09762f9ab9b3a89147d882344dad8d1f5 With the following code:
async function a() {
var x = await foo();
}
I get the following error
geza@gezamac ~> sjs --no-babel ~/test3.js
/usr/local/lib/node_modules/sweet.js/node_modules/babel-core/lib/transformation/file/index.js:590
throw err;
^
SyntaxError: unknown: await is a reserved word (3:12)
1 | async;
2 | function a() {
> 3 | var x_0 = await;
| ^
4 | foo();
5 | }
6 |
at Parser.pp$5.raise (/usr/local/lib/node_modules/sweet.js/node_modules/babylon/lib/index.js:4373:13)
at Parser.pp$3.checkReservedWord (/usr/local/lib/node_modules/sweet.js/node_modules/babylon/lib/index.js:4266:10)
at Parser.pp$3.parseIdentifier (/usr/local/lib/node_modules/sweet.js/node_modules/babylon/lib/index.js:4243:10)
at Parser.pp$3.parseExprAtom (/usr/local/lib/node_modules/sweet.js/node_modules/babylon/lib/index.js:3581:21)
at Parser.pp$3.parseExprSubscripts (/usr/local/lib/node_modules/sweet.js/node_modules/babylon/lib/index.js:3427:19)
at Parser.pp$3.parseMaybeUnary (/usr/local/lib/node_modules/sweet.js/node_modules/babylon/lib/index.js:3407:19)
at Parser.pp$3.parseExprOps (/usr/local/lib/node_modules/sweet.js/node_modules/babylon/lib/index.js:3337:19)
at Parser.pp$3.parseMaybeConditional (/usr/local/lib/node_modules/sweet.js/node_modules/babylon/lib/index.js:3314:19)
at Parser.pp$3.parseMaybeAssign (/usr/local/lib/node_modules/sweet.js/node_modules/babylon/lib/index.js:3277:19)
at Parser.pp$1.parseVar (/usr/local/lib/node_modules/sweet.js/node_modules/babylon/lib/index.js:2295:24)
Result is same if I don't use the --no-babel option
The reader and enforester don't currently handle async and await.
@disnet we'll have to update sweet-spec, and tokens, enforester, etc. and the version of shift-codegen I think.
shift doesn't have es2017 (async/await) support just yet so we're blocked on that. I hear it's being prioritized soon though.