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

fix(es/lexer): Make Capturing respect reset_to #7637

Closed
wants to merge 1 commit into from

Conversation

kdy1
Copy link
Member

@kdy1 kdy1 commented Jul 7, 2023

@kdy1 kdy1 self-assigned this Jul 7, 2023
break;
}
}

Copy link
Contributor

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?

Copy link
Contributor

@dsherret dsherret Jul 13, 2023

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)

Copy link
Member Author

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #7807

@kdy1
Copy link
Member Author

kdy1 commented Feb 13, 2024

Closing as obsolete

@kdy1 kdy1 closed this Feb 13, 2024
@kdy1 kdy1 deleted the issue-7621 branch February 13, 2024 05:20
@kdy1 kdy1 modified the milestones: Planned, v1.4.1 Feb 13, 2024
@swc-project swc-project locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Left shift in binary expression op is lexed as two < instead of as <<
2 participants