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

Debug panic when parsing an arrow expression with a type annotation in a conditional expression #141

Closed
ry opened this issue Mar 9, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@ry
Copy link

ry commented Mar 9, 2020

On this file: https://github.com/denoland/deno/blob/2115b38fef654c2d7c5998f40967fcfe39d7c515/cli/js/compiler_imports.ts

> RUST_BACKTRACE=1 ./target/debug/deno fmt cli/js/compiler_imports.ts
thread 'main' panicked at 'Debug panic: Node comments retrieved out of order!', /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:336:13
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:84
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1025
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:193
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:471
  11: parking_lot_core::word_lock::WordLock::unlock_slow
  12: dprint_plugin_typescript::parser::parse_node_with_inner_parse::assert_parsed_in_order
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:336
  13: dprint_plugin_typescript::parser::parse_node_with_inner_parse
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:48
  14: dprint_plugin_typescript::parser::parse_comma_separated_value
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4418
  15: dprint_plugin_typescript::parser::parse_separated_values::{{closure}}
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4386
  16: dprint_plugin_typescript::helpers::parse_separated_values::parse_separated_values
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/helpers/parse_separated_values.rs:48
  17: dprint_plugin_typescript::parser::parse_separated_values
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4379
  18: dprint_plugin_typescript::parser::parse_parameters_or_arguments::{{closure}}
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4264
  19: dprint_plugin_typescript::parser::parse_surrounded_by_tokens
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:5446
  20: dprint_plugin_typescript::parser::parse_parameters_or_arguments
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4248
  21: dprint_plugin_typescript::parser::parse_arrow_func_expr
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:1080
  22: dprint_plugin_typescript::parser::parse_node_with_inner_parse::parse_node_inner
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:107
  23: dprint_plugin_typescript::parser::parse_node_with_inner_parse
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:62
  24: dprint_plugin_typescript::parser::parse_conditional_expr
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:1574
  25: dprint_plugin_typescript::parser::parse_node_with_inner_parse::parse_node_inner
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:113
  26: dprint_plugin_typescript::parser::parse_node_with_inner_parse
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:62
  27: dprint_plugin_typescript::parser::parse_node
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:31
  28: dprint_plugin_typescript::parser::parse_expr_or_spread
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:1630
  29: dprint_plugin_typescript::parser::parse_node_with_inner_parse::parse_node_inner
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:114
  30: dprint_plugin_typescript::parser::parse_node_with_inner_parse
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:62
  31: dprint_plugin_typescript::parser::parse_comma_separated_value
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4418
  32: dprint_plugin_typescript::parser::parse_separated_values::{{closure}}
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4386
  33: dprint_plugin_typescript::helpers::parse_separated_values::parse_separated_values
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/helpers/parse_separated_values.rs:48
  34: dprint_plugin_typescript::parser::parse_separated_values
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4379
  35: dprint_plugin_typescript::parser::parse_parameters_or_arguments::{{closure}}
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4264
  36: dprint_plugin_typescript::parser::parse_surrounded_by_tokens
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:5446
  37: dprint_plugin_typescript::parser::parse_parameters_or_arguments
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4248
  38: dprint_plugin_typescript::parser::parse_call_expr::inner_parse
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:1427
  39: dprint_plugin_typescript::parser::parse_call_expr
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:1411
  40: dprint_plugin_typescript::parser::parse_node_with_inner_parse::parse_node_inner
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:111
  41: dprint_plugin_typescript::parser::parse_node_with_inner_parse
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:62
  42: dprint_plugin_typescript::parser::parse_node
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:31
  43: dprint_plugin_typescript::parser::parse_assignment
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:5346
  44: dprint_plugin_typescript::parser::parse_var_declarator
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:3315
  45: dprint_plugin_typescript::parser::parse_node_with_inner_parse::parse_node_inner
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:208
  46: dprint_plugin_typescript::parser::parse_node_with_inner_parse
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:62
  47: dprint_plugin_typescript::parser::parse_node
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:31
  48: dprint_plugin_typescript::parser::parse_var_decl
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:3291
  49: dprint_plugin_typescript::parser::parse_node_with_inner_parse::parse_node_inner
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:207
  50: dprint_plugin_typescript::parser::parse_node_with_inner_parse
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:62
  51: dprint_plugin_typescript::parser::parse_node
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:31
  52: dprint_plugin_typescript::parser::parse_statements_or_members
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4192
  53: dprint_plugin_typescript::parser::parse_statements
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4132
  54: dprint_plugin_typescript::parser::parse_block_stmt::{{closure}}
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:2636
  55: dprint_plugin_typescript::parser::parse_block::{{closure}}
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:5384
  56: dprint_plugin_typescript::parser::parse_surrounded_by_tokens
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:5446
  57: dprint_plugin_typescript::parser::parse_block
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:5375
  58: dprint_plugin_typescript::parser::parse_block_stmt
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:2635
  59: dprint_plugin_typescript::parser::parse_node_with_inner_parse::parse_node_inner
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:187
  60: dprint_plugin_typescript::parser::parse_node_with_inner_parse
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:62
  61: dprint_plugin_typescript::parser::parse_node
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:31
  62: dprint_plugin_typescript::parser::parse_function_decl_or_expr
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:833
  63: dprint_plugin_typescript::parser::parse_function_decl
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:772
  64: dprint_plugin_typescript::parser::parse_node_with_inner_parse::parse_node_inner
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:95
  65: dprint_plugin_typescript::parser::parse_node_with_inner_parse
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:62
  66: dprint_plugin_typescript::parser::parse_node
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:31
  67: dprint_plugin_typescript::parser::parse_export_decl
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:661
  68: dprint_plugin_typescript::parser::parse_node_with_inner_parse::parse_node_inner
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:92
  69: dprint_plugin_typescript::parser::parse_node_with_inner_parse
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:62
  70: dprint_plugin_typescript::parser::parse_node
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:31
  71: dprint_plugin_typescript::parser::parse_statements_or_members
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4192
  72: dprint_plugin_typescript::parser::parse_statements
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:4132
  73: dprint_plugin_typescript::parser::parse_module
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:2424
  74: dprint_plugin_typescript::parser::parse_node_with_inner_parse::parse_node_inner
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:177
  75: dprint_plugin_typescript::parser::parse_node_with_inner_parse
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:62
  76: dprint_plugin_typescript::parser::parse_node
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:31
  77: dprint_plugin_typescript::parser::parse
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/parser.rs:21
  78: dprint_plugin_typescript::format_text::format_text::{{closure}}
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/format_text.rs:41
  79: scoped_tls::ScopedKey<T>::set
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137
  80: dprint_plugin_typescript::format_text::format_text
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/dprint-plugin-typescript-0.8.0/src/format_text.rs:35
  81: deno::fmt::format_source_files::{{closure}}
             at cli/fmt.rs:107
  82: std::panicking::try::do_call
             at /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libstd/panicking.rs:292
  83: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:78
  84: std::panicking::try
             at /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libstd/panicking.rs:270
  85: std::panic::catch_unwind
             at /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libstd/panic.rs:394
  86: deno::fmt::format_source_files
             at cli/fmt.rs:106
  87: deno::fmt::format
             at cli/fmt.rs:170
  88: deno::main::{{closure}}
             at cli/lib.rs:447
  89: <std::future::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libstd/future.rs:43
  90: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libcore/future/future.rs:119
  91: tokio::runtime::basic_scheduler::BasicScheduler<P>::block_on
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.13/src/runtime/basic_scheduler.rs:138
  92: tokio::runtime::Runtime::block_on::{{closure}}
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.13/src/runtime/mod.rs:413
  93: tokio::runtime::context::enter
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.13/src/runtime/context.rs:72
  94: tokio::runtime::handle::Handle::enter
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.13/src/runtime/handle.rs:34
  95: tokio::runtime::Runtime::block_on
             at /Users/rld/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.13/src/runtime/mod.rs:410
  96: deno::tokio_util::run_basic
             at cli/tokio_util.rs:18
  97: deno::main
             at cli/lib.rs:486
  98: deno::main
             at cli/main.rs:4
  99: std::rt::lang_start::{{closure}}
             at /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libstd/rt.rs:67
 100: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
 101: std::panicking::try::do_call
             at src/libstd/panicking.rs:292
 102: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:78
 103: std::panicking::try
             at src/libstd/panicking.rs:270
 104: std::panic::catch_unwind
             at src/libstd/panic.rs:394
 105: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
 106: std::rt::lang_start
             at /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libstd/rt.rs:67
 107: deno::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
dprint panic cli/js/compiler_imports.ts
@dsherret
Copy link
Member

dsherret commented Mar 9, 2020

Thanks for reporting. Occurs because of an arrow expression span is incorrect in swc:

Node kind: ArrowExpr
Text: ": string => resolveSpecifier(specifier, referrer)"

Minimal reproduction:

referrer
  ? false
  : ([, specifier]): string => specifier;

@dsherret dsherret added the bug Something isn't working label Mar 9, 2020
@dsherret dsherret changed the title panic with 0.8.0: Node comments retrieved out of order! Debug panic when parsing an arrow expression with a type annotation in a conditional expression Mar 9, 2020
@dsherret
Copy link
Member

Opened swc-project/swc#712

dsherret added a commit that referenced this issue Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants