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

fmt command panicked by throw statement #5567

Closed
srackham opened this issue May 17, 2020 · 3 comments · Fixed by #5734
Closed

fmt command panicked by throw statement #5567

srackham opened this issue May 17, 2020 · 3 comments · Fixed by #5734
Labels
bug Something isn't working correctly cli related to cli/ dir

Comments

@srackham
Copy link

The snippet below compiles and runs but causes the fmt command to panic:

$ deno --version
deno 1.0.0
v8 8.4.300
typescript 3.9.2

$ cat deno-fmt-panic.ts 
try {
  throw new TypeError
}
catch {
}

$ deno run deno-fmt-panic.ts 
Compile file:///home/srackham/local/projects/drake/tmp/deno-fmt-panic.ts

$ deno fmt deno-fmt-panic.ts 
thread 'tokio-runtime-worker' panicked at 'Expected to find a close paren token.', /home/runner/work/deno/deno/.cargo_home/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.17.2/src/parsing/parser_types.rs:787:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'Panic formatting: deno-fmt-panic.ts', cli/fmt.rs:232:5

@kitsonk
Copy link
Contributor

kitsonk commented May 17, 2020

Currently deno fmt panics on bad syntax like the above (new TypeError is invalid syntax as it is missing the parens), maybe it should raise one of the conformed errors.

@dsherret
Copy link
Member

It would be good to improve it not to panic in these scenarios. I'll look into this.

@bartlomieju bartlomieju added bug Something isn't working correctly cli related to cli/ dir labels May 18, 2020
@bartlomieju
Copy link
Member

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 cli related to cli/ dir
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants