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 when parsing certain structures #10112

Closed
kitsonk opened this issue Apr 10, 2021 · 6 comments
Closed

Panic when parsing certain structures #10112

kitsonk opened this issue Apr 10, 2021 · 6 comments
Labels
bug Something isn't working correctly swc related to swc (bundling/transpiling)

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Apr 10, 2021

In Deno main, the following code will cause a panic:

function a() {
  try {}
}

Something along the lines of:

thread 'main' panicked at 'internal error: entered unreachable code: assertion failed: (span.start <= span.end).
 start = 24, end = 23', /Users/kitsonk/.cargo/registry/src/github.com-1ecc6299db9ec823/swc_ecma_parser-0.54.0/src/parser/stmt.rs:549:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I discovered the issue while using the Deno LSP and typing a try {} block in the editor, which is a common pattern when attempting to write out a try...catch block in a function. While the syntax isn't invalid, swc shouldn't be panicing.

cc/ @kdy1

@kitsonk kitsonk added bug Something isn't working correctly swc related to swc (bundling/transpiling) labels Apr 10, 2021
@kdy1
Copy link

kdy1 commented Apr 10, 2021

I'll fix it soon.

Btw, are you going to swc's parser for lsp?

kdy1 added a commit to kdy1/swc that referenced this issue Apr 10, 2021
kdy1 added a commit to swc-project/swc that referenced this issue Apr 10, 2021
swc_ecma_parser:
 - Don't panic for `try` statements without handler and finalizer. (denoland/deno#10112)

swc_ecma_transforms_base:
 - Fix `typeof`s used with `externalHelpers: true`. (#1458, #1557)
@kitsonk
Copy link
Contributor Author

kitsonk commented Apr 10, 2021

@kdy1 yes, we use it for dependency analysis and for certain code completions. We are also going to use it to detect some symbols like Deno.test so we can provide more intelligence, but also deno format and deno lint are integrated into the lsp which also use the parser.

@nayeemrmn
Copy link
Collaborator

@kitsonk Is this fixed?

@kitsonk
Copy link
Contributor Author

kitsonk commented Apr 25, 2021

Don't know. Haven't had to the time to validate that the PR in swc was released and the Deno has updated to that release or later.

@nayeemrmn
Copy link
Collaborator

We have as of 1.9.0, I made a list of issues that were fixed but didn't know how to repro this one to confirm.

@kitsonk
Copy link
Contributor Author

kitsonk commented Apr 25, 2021

I just tried it off a recent version of main and it no longer occurs.

@kitsonk kitsonk closed this as completed Apr 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly swc related to swc (bundling/transpiling)
Projects
None yet
Development

No branches or pull requests

3 participants