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

Code causes syntax tree thread to terminate #129

Closed
devonpmack opened this issue Aug 9, 2022 · 0 comments · Fixed by #132
Closed

Code causes syntax tree thread to terminate #129

devonpmack opened this issue Aug 9, 2022 · 0 comments · Fixed by #132

Comments

@devonpmack
Copy link

devonpmack commented Aug 9, 2022

Running syntax tree on this code crashes it

LongRecordName.transaction do
  LongRecordName
    .joins(:other_record)
    # rubocop:disable Rails/SkipsModelValidations

    .update_all(foo: 'bar')
end

Error:

[warn] foo.rb
Error: Cannot find expected end
#<Thread:0x0000000108fc4898 /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/cli.rb:382 run> terminated with exception (report_on_exception is true):
/Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/cli.rb:426:in `highlight_error': undefined method `+' for nil:NilClass (NoMethodError)

        maximum = [error.lineno + 3, lines.length].min
                                ^
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/cli.rb:401:in `rescue in block (2 levels) in process_queue'
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/cli.rb:396:in `block (2 levels) in process_queue'
/Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/parser.rb:210:in `find_token': Cannot find expected end (SyntaxTree::Parser::ParseError)
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/parser.rb:1198:in `on_do_block'
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree.rb:46:in `parse'
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree.rb:46:in `parse'
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree.rb:53:in `format'
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/cli.rb:104:in `run'
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/cli.rb:397:in `block (2 levels) in process_queue'
/Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/cli.rb:426:in `highlight_error': undefined method `+' for nil:NilClass (NoMethodError)

        maximum = [error.lineno + 3, lines.length].min
                                ^
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/cli.rb:401:in `rescue in block (2 levels) in process_queue'
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/cli.rb:396:in `block (2 levels) in process_queue'
/Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/parser.rb:210:in `find_token': Cannot find expected end (SyntaxTree::Parser::ParseError)
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/parser.rb:1198:in `on_do_block'
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree.rb:46:in `parse'
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree.rb:46:in `parse'
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree.rb:53:in `format'
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/cli.rb:104:in `run'
        from /Users/devon/.gem/ruby/3.1.2/gems/syntax_tree-3.3.0/lib/syntax_tree/cli.rb:397:in `block (2 levels) in process_queue'

Expected

Shows syntax error, but no stack trace

@devonpmack devonpmack changed the title Code causes syntax tree to crash Code causes syntax tree thread to terminate Aug 9, 2022
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.

1 participant