Skip to content

Bug formating code, possibly? #297

Closed
@stoivo

Description

@stoivo

I think I have found a bug. I think this code should work.

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'syntax_tree', '5.3.0'
end

require "syntax_tree"

source = <<~RUBY
with_options bookkeeping_account_number: 12 do
  validates :bookkeeping_number
end
RUBY

program = SyntaxTree.parse(source)
program => { statements: { body: [binary] } }

formatter = SyntaxTree::Formatter.new(source, [])
binary.format(formatter)

formatter.flush
formatter.output.join

right now I get

untitled2.rb:26: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!                                                                                                                                                                                                               
/Users/simon/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/syntax_tree-5.3.0/lib/syntax_tree/node.rb:4374:in `forced_do_end_bounds?': undefined method `call' for nil:NilClass (NoMethodError)                                                                                                                                        
        from /Users/simon/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/syntax_tree-5.3.0/lib/syntax_tree/node.rb:4308:in `format'                                                                                                                                                                                                    
        from /Users/simon/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/syntax_tree-5.3.0/lib/syntax_tree/formatter.rb:168:in `format'                                                                                                                                                                                                
        from /Users/simon/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/syntax_tree-5.3.0/lib/syntax_tree/node.rb:3434:in `format'                                                                                                                                                                                                    
        from untitled2.rb:29:in `<main>'   

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions