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

Panic on parsing TypeScript syntax #2198

Closed
kitsonk opened this issue Sep 2, 2021 · 2 comments · Fixed by #2222
Closed

Panic on parsing TypeScript syntax #2198

kitsonk opened this issue Sep 2, 2021 · 2 comments · Fixed by #2222
Labels
Milestone

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Sep 2, 2021

Describe the bug

The following code will cause a panic when being parsed. It isn't valid, but it should parse and allow diagnostics to be returned.

thread 'main' panicked at 'internal error: entered unreachable code: parse_lit should not be called', /Users/lucacasonato/.cargo/registry/src/github.com-1ecc6299db9ec823/swc_ecma_parser-0.66.2/src/parser/expr.rs:1574:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Input code

function imp<T extends string>(x: T): typeof import(T) {
    return x;
}

console.log("123");

Expected behavior

No panic.

Version

swc_parser 0.66

Additional context

Ref: denoland/deno#11898

@kitsonk kitsonk added the C-bug label Sep 2, 2021
@kdy1 kdy1 modified the milestones: v1.2.85, v1.2.86 Sep 2, 2021
@kdy1 kdy1 mentioned this issue Sep 9, 2021
@kdy1
Copy link
Member

kdy1 commented Sep 9, 2021

@kitsonk Is this valid syntax? If so, the AST definition of TsImportType is wrong.

Edit:
NVM. I found that it's about panic.

kdy1 added a commit to kdy1/swc that referenced this issue Sep 9, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Sep 9, 2021
@kdy1 kdy1 closed this as completed in #2222 Sep 9, 2021
kdy1 added a commit that referenced this issue Sep 9, 2021
swc_ecma_parser:
 - Don't panic on `typeof import(T)`. (#2198)
 - Fix parsing of ternary. (#2196)

swc_ecma_transforms_base:
 - `fixer`: Handle unary in lhs of an exponentation expression. (#2191)

swc_ecma_transforms_compat:
 - Use variable for `this` in arrow expressions. (#2212)

swc_ecma_visit:
 - Add a trait `InjectVars`.

node_swc:
 - Increease recursion limit while deserializing. (#2223)
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 22, 2022

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 Oct 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants