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

Left shift in binary expression op is lexed as two < instead of as << #7621

Closed
dsherret opened this issue Jul 3, 2023 · 4 comments · Fixed by #8634
Closed

Left shift in binary expression op is lexed as two < instead of as << #7621

dsherret opened this issue Jul 3, 2023 · 4 comments · Fixed by #8634

Comments

@dsherret
Copy link
Contributor

dsherret commented Jul 3, 2023

Describe the bug

Probably caused by https://github.com/swc-project/swc/pull/7439/files

Tokens for `a << 1`: [
    TokenAndSpan {
        token: a,
        had_line_break: false,
        span: Span {
            lo: BytePos(
                101,
            ),
            hi: BytePos(
                102,
            ),
            ctxt: #0,
        },
    },
    TokenAndSpan {
        token: <,
        had_line_break: false,
        span: Span {
            lo: BytePos(
                103,
            ),
            hi: BytePos(
                104,
            ),
            ctxt: #0,
        },
    },
    TokenAndSpan {
        token: <,
        had_line_break: false,
        span: Span {
            lo: BytePos(
                104,
            ),
            hi: BytePos(
                105,
            ),
            ctxt: #0,
        },
    },
    TokenAndSpan {
        token: numeric literal (1, 1),
        had_line_break: false,
        span: Span {
            lo: BytePos(
                106,
            ),
            hi: BytePos(
                107,
            ),
            ctxt: #0,
        },
    },
]

Input code

const test = a << 1;

Config

No response

Playground link

No response

Expected behavior

Lexed as a, <<, 1

Actual behavior

Lexed as a, <, <, 1

Version

swc_ecma_parser 0.137.1

Additional context

No response

@dsherret dsherret added the C-bug label Jul 3, 2023
@dsherret
Copy link
Contributor Author

dsherret commented Jul 3, 2023

One interesting point is that the op in the AST is correctly parsed as <<, so maybe this is not considered a bug, but it would be nice if they aligned. (I do wonder if the backtracking is causing issues though)

@kdy1
Copy link
Member

kdy1 commented Jul 4, 2023

Can you post the rust code?

@kdy1
Copy link
Member

kdy1 commented Jul 4, 2023

Ah nevermind I know the cause

@kdy1 kdy1 added this to the Planned milestone Jul 4, 2023
@kdy1 kdy1 assigned kdy1 and unassigned kdy1 Jul 4, 2023
kdy1 pushed a commit that referenced this issue Aug 14, 2023
This temporarily reverts commit 6850372
until #7621 can be fixed.

Re-opens #7187.
kdy1 pushed a commit to kdy1/swc that referenced this issue Aug 15, 2023
This temporarily reverts commit 6850372
until swc-project#7621 can be fixed.

Re-opens swc-project#7187.
kdy1 added a commit that referenced this issue Feb 13, 2024
**Related issue:**

 - Closes #7621.
@kdy1 kdy1 modified the milestones: Planned, v1.4.2 Feb 19, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Mar 20, 2024

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
3 participants