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 wrapping array destructuring in brackets #416

Open
jakubkosinski opened this issue Feb 22, 2023 · 1 comment · May be fixed by #419
Open

Panic when wrapping array destructuring in brackets #416

jakubkosinski opened this issue Feb 22, 2023 · 1 comment · May be fixed by #419
Assignees

Comments

@jakubkosinski
Copy link

  • Ruby version: 3.1.3
  • Rubyfmt git sha: 266b47b

Input file

(a, *b) = ARGV

Rubyfmt's output

thread 'main' panicked at 'failed to convert', librubyfmt/src/parser_state.rs:949:18
stack backtrace:
   0: std::panicking::begin_panic
   1: rubyfmt::parser_state::BaseParserState::push_abstract_token
   2: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::emit_soft_indent
   3: core::ops::function::FnOnce::call_once{{vtable.shim}}
   4: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
   5: core::ops::function::FnOnce::call_once{{vtable.shim}}
   6: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
   7: core::ops::function::FnOnce::call_once{{vtable.shim}}
   8: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
   9: rubyfmt::format::format_massign
  10: rubyfmt::format::format_expression
  11: rubyfmt::format::format_program
  12: rubyfmt::format_buffer
  13: rubyfmt_main::iterate_formatted::{{closure}}
  14: rubyfmt_main::iterate_formatted
  15: rubyfmt_main::main

This breaks because

Main thread panics at failed to convert

@reese reese self-assigned this Mar 11, 2023
@reese reese linked a pull request Mar 11, 2023 that will close this issue
@bquorning
Copy link
Contributor

I am seeing a similar issue, using v0.8.1 on Linux. On Mac, rubyfmt v0.8.1 parses the same code with no issues 🤷🏼

   0: std::panicking::begin_panic
   1: rubyfmt::parser_state::BaseParserState::push_abstract_token
   2: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::emit_soft_indent
   3: core::ops::function::FnOnce::call_once{{vtable.shim}}
   4: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
   5: core::ops::function::FnOnce::call_once{{vtable.shim}}
   6: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
   7: core::ops::function::FnOnce::call_once{{vtable.shim}}
   8: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
   9: rubyfmt::format::format_massign
  10: rubyfmt::format::format_expression
  11: rubyfmt::format::format_bodystmt
  12: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
  13: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::new_block
  14: rubyfmt::format::format_block
  15: rubyfmt::format::format_call_chain_elements
  16: core::ops::function::FnOnce::call_once{{vtable.shim}}
  17: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
  18: rubyfmt::format::format_method_add_block
  19: rubyfmt::format::format_expression
  20: rubyfmt::format::format_bodystmt
  21: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
  22: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::new_block
  23: rubyfmt::format::format_block
  24: rubyfmt::format::format_call_chain_elements
  25: core::ops::function::FnOnce::call_once{{vtable.shim}}
  26: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
  27: rubyfmt::format::format_method_add_block
  28: rubyfmt::format::format_expression
  29: rubyfmt::format::format_bodystmt
  30: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
  31: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::new_block
  32: rubyfmt::format::format_block
  33: rubyfmt::format::format_call_chain_elements
  34: core::ops::function::FnOnce::call_once{{vtable.shim}}
  35: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
  36: rubyfmt::format::format_method_add_block
  37: rubyfmt::format::format_expression
  38: rubyfmt::format::format_bodystmt
  39: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
  40: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::new_block
  41: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_formatting_context
  42: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::new_scope
  43: rubyfmt::format::format_def
  44: rubyfmt::format::format_expression
  45: rubyfmt::format::format_bodystmt
  46: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_formatting_context
  47: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
  48: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::new_block
  49: rubyfmt::format::format_constant_body
  50: rubyfmt::format::format_expression
  51: rubyfmt::format::format_bodystmt
  52: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_formatting_context
  53: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
  54: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::new_block
  55: rubyfmt::format::format_constant_body
  56: rubyfmt::format::format_expression
  57: rubyfmt::format::format_bodystmt
  58: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_formatting_context
  59: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
  60: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::new_block
  61: rubyfmt::format::format_constant_body
  62: rubyfmt::format::format_expression
  63: rubyfmt::format::format_bodystmt
  64: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_formatting_context
  65: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::with_start_of_line
  66: <rubyfmt::parser_state::BaseParserState as rubyfmt::parser_state::ConcreteParserState>::new_block
  67: rubyfmt::format::format_constant_body
  68: rubyfmt::format::format_expression
  69: rubyfmt::format::format_program
  70: rubyfmt::format_buffer
  71: rubyfmt_main::iterate_formatted::{{closure}}
  72: rubyfmt_main::iterate_formatted
  73: rubyfmt_main::main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants