-
-
Notifications
You must be signed in to change notification settings - Fork 6
Strange parser error when an if
statement is at the top of an async arrow function
#61
Comments
Hey there! 👋 Thanks for the report, it sounds me like problem here. The idea about that Can you try to add this check too and try again if it works const isAsyncArrow = result.value.startsWith('async')
if (!(isFunction || isAsyncFn || isAsyncArrow) && isMethod) {
result.value = `{ ${result.value} }`
} Another reason and probably limitation is that we use |
@charlike The patch works for me 👍 Thank you for the quick turnaround on that! |
Sweeeet! :D I love myself sometimes for such fast responses with good end :) PR is welcome, otherwise i can push patch in coming days. Let me know if you need some help on contributing. |
Well it's your patch. I look forward to the upcoming release 👍 |
🐯🐯🐯🐯🐯🐯🐯🐯 |
@the1mills what? 😹 haha @TooTallNate actually, yea, but it's not a problem for me. Go pr if you need it more soon. |
* add case for async arrow functions when wrapping Fixes #61. * add missing `done()` to test case
heya, just seen your comment here.
no, it's not, just i'm in period of switching ISP providers and following through smartphone is hard, haha. i'll add you once I get stability and time, no problem :) |
(a = (doSomething(), doSomethingElse(), true)) => {} is a prefectly valid syntax that is used extensively by code instrumenters. When a list of expressions is used as a default value, only the last expression is the actual default value. This commit add support for this syntax. TAG: latest fixes tunnckoCore#61
Apologies if this is not a bug in
parse-function
itself, but I've tried this with all 3 recommended AST parsers and they all exhibit the same problem.A parser error is thrown when an async arrow function has an
if
statement at the top. Ex:Strangely, the same error is thrown even if the
if
statement is commented out!Now, it works if I remove the
if
statement:It also works if I change it to a regular async function instead of an arrow function:
So, strange behavior to say the least. Or maybe I'm doing something dumb. V8 at least has no problem parsing any of these versions. Thanks in advance for any support!
The text was updated successfully, but these errors were encountered: