-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(es/lexer): Make Capturing
respect reset_to
#7637
Conversation
break; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is still a draft, but I just tried this out because I was curious and the issue still occurs with const test = a << 1;
.
Looking into it, here's what occurs for const test = a << 1
:
Storing: const
Storing: test
Storing: =
Storing: a
Storing: <<
Reset to: [
const,
test,
=,
a,
]
Storing: <
Storing: <
Storing: numeric literal (1, 1)
Reset to: [
const,
test,
=,
a,
]
Storing: <
Storing: <
Storing: numeric literal (1, 1)
Storing: numeric literal (1, 1)
Storing: ;
So my guess would be that the parser is parsing it correctly the first time, then checking out two other possible routes, then opting for the first and keeping that node, but now the capturer has incorrect tokens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would make sense to store the tokens as a singly linked list, similar to this change with how comments are stored: https://github.com/swc-project/swc/pull/2407/files#diff-43ba5d4e02f7fa5b4ed8f187ed2337705e09f8574ad590d426f45bd4ebb64c87 (I don't have enough knowledge of the codebase to know though and I'm just guessing what's occurring here atm)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your guess is exactly correct, and I didn't think about singly linked list, but I'll try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some code in https://github.com/swc-project/swc/pull/7692/files for this idea, but unfortunately the test from #7187 is failing for some reason, but I'm not sure why my change caused it to start failing again. There's probably something I didn't account for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kdy1 would you accept a PR to revert #7439 in the short term? It's preventing me from upgrading swc and with TypeScript 5.2 being released in a couple weeks it would provide me with an upgrade path. Otherwise, do you know a way we could fix this? I struggled a bit to find the issue in #7692, but I haven't had much time to look into it more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dsherret Can you send a PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened #7807
Closing as obsolete |
Description:
Related issue:
<
instead of as<<
#7621.