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

cannot find first or last token in PlusOp node #425

Closed
danielbprice opened this issue Sep 20, 2016 · 3 comments
Closed

cannot find first or last token in PlusOp node #425

danielbprice opened this issue Sep 20, 2016 · 3 comments
Assignees

Comments

@danielbprice
Copy link

I am using decaffeinate 2.23.1. decaffeinate is crashing on my CoffeeScript input:

abc = "Hello there,"

x = "#{abc} this should trigger a message about" + \
    "invalid plusops"

(repl)

a.coffee: cannot find first or last token in PlusOp node
  2 | abc = "Hello there,"
  3 |
> 4 | x = "#{abc} this should trigger a message about" + \
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  5 |     "invalid plusops"
  6 |
@danielbprice
Copy link
Author

(removing the "plus" from line 4 and using a simple string works fine).

@danielbprice
Copy link
Author

Might be related to bug #389.

@alangpierce
Copy link
Member

Thanks for the report! Here's the decaffeinate-parser output for a minified test case: repl.

Looks to me like a decaffeinate-parser bug: it's parsing it as two PlusOps when it should be parsing it to a TemplateLiteral. The CoffeeScript lexer/parser loses template literal information, so decaffeinate-parser tries to reconstruct it, and it looks like that's what's going wrong here.

alangpierce added a commit to alangpierce/decaffeinate-parser that referenced this issue Oct 30, 2016
Closes decaffeinate/decaffeinate#425

There was already some logic to distinguish between explicit `+` operations and
implicit ones generated as part of string interpolation parsing, but that logic
wasn't used in all places. Now, we also use it in `isInterpolatedString`, which
avoids a problem where `+` was seen as a string interpolation in some cases.
alangpierce added a commit to alangpierce/decaffeinate-parser that referenced this issue Oct 30, 2016
Closes decaffeinate/decaffeinate#425

There was already some logic to distinguish between explicit `+` operations and
implicit ones generated as part of string interpolation parsing, but that logic
wasn't used in all places. Now, we also use it in `isInterpolatedString`, which
avoids a problem where `+` was seen as a string interpolation in some cases.
alangpierce added a commit to alangpierce/decaffeinate-parser that referenced this issue Oct 30, 2016
Closes decaffeinate/decaffeinate#425

There was already some logic to distinguish between explicit `+` operations and
implicit ones generated as part of string interpolation parsing, but that logic
wasn't used in all places. Now, we also use it in `isInterpolatedString`, which
avoids a problem where `+` was seen as a string interpolation in some cases.
@alangpierce alangpierce self-assigned this Oct 30, 2016
alangpierce added a commit to decaffeinate/decaffeinate-parser that referenced this issue Oct 30, 2016
Closes decaffeinate/decaffeinate#425
Closes decaffeinate/decaffeinate#194

There was already some logic to distinguish between explicit `+` operations and
implicit ones generated as part of string interpolation parsing, but that logic
wasn't used in all places. Now, we also use it in `isInterpolatedString`, which
avoids a problem where `+` was seen as a string interpolation in some cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants