Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optional chaining inside do() argument list #1482

Open
IlyaSkriblovsky opened this issue Sep 6, 2019 · 2 comments
Open

optional chaining inside do() argument list #1482

IlyaSkriblovsky opened this issue Sep 6, 2019 · 2 comments

Comments

@IlyaSkriblovsky
Copy link

decaffeinate is crashing on my CoffeeScript input:

do (a = b?.c) ->

(repl)

I get this error:

stdin: AddVariableDeclarationsStage failed to parse: The type cast expression is expected to be wrapped with parenthesis (1:21)
> 1 | (function(a) {})(b.c : undefined));
    |                      ^
  2 | 
@eventualbuddha
Copy link
Collaborator

This looks like a bad interaction between patchers. I don't have a good idea what's causing this yet, but I'll look into it.

@eventualbuddha
Copy link
Collaborator

Leaving a note with the exploration I did. It looks like the getPatchedSource that DoOpPatcher does for the default param value only gets b.c : undefined instead of the full typeof b !== 'undefined' && b !== null ? b.c : undefined. I initially thought it may have to do with the deferred patching that SoakedMemberAccessOpPatcher does, but I don't think that's it. I tried expanding the getPatchedSource from contentStart through contentEnd to be inner* or outer*, but that didn't work either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants