This repository was archived by the owner on Feb 8, 2020. It is now read-only.
This repository was archived by the owner on Feb 8, 2020. It is now read-only.
Arrow function with inner function fails to parse #179
Open
Description
The following snippet fails to parse because result.value
is erroneously(?) wrapped in { ... }
on line https://github.com/tunnckoCoreLabs/parse-function/blob/master/src/index.js#L119-L121
import parseFunction from 'parse-function'
parseFunction().parse(arg => new Promise(resolve => {
function inner() {}
inner()
}))
babylon
/ @babel/parser
throws the following error:
SyntaxError: Unexpected token, expected "," (1:6)
at Parser.raise (node_modules/babylon/lib/index.js:776:15)
at Parser.unexpected (node_modules/babylon/lib/index.js:2079:16)
at Parser.expect (node_modules/babylon/lib/index.js:2067:28)
at Parser.parseObj (node_modules/babylon/lib/index.js:3465:14)
at Parser.parseExprAtom (node_modules/babylon/lib/index.js:3123:21)
at Parser.parseExprSubscripts (node_modules/babylon/lib/index.js:2757:21)
at Parser.parseMaybeUnary (node_modules/babylon/lib/index.js:2736:21)
at Parser.parseExprOps (node_modules/babylon/lib/index.js:2643:21)
at Parser.parseMaybeConditional (node_modules/babylon/lib/index.js:2615:21)
at Parser.parseMaybeAssign (node_modules/babylon/lib/index.js:2562:21)
Maybe just add isArrow
to the if on line 119? Or might that cause problems with arrow functions in normal function bodies because the includes('=>')
is too greedy and should only look at the start?