Skip to content

"private method `format' called for nil:NilClass" exception due to "no anonymous block parameter (SyntaxError)" in Rake check task #481

Open
@floehopper

Description

@floehopper

This seems unrelated to #371 even though the exception looks the same.

# no_anomymous_block_parameter.rb

def foo
  bar(&)
end
# reproduce.rb

require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "rake"
  gem "syntax_tree"
end

require "syntax_tree/rake_tasks"

SyntaxTree::Rake::CheckTask.new("check") do |t|
  t.source_files = FileList["no_anomymous_block_parameter.rb"]
end

Rake::Task["check"].invoke
$ ruby --version
ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin22]

$ ruby reproduce.rb

[warn] foo.rb
private method `format' called for nil:NilClass
~/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/syntax_tree-6.2.0/lib/syntax_tree.rb:94:in `format_node'
~/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/syntax_tree-6.2.0/lib/syntax_tree.rb:66:in `format'
~/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/syntax_tree-6.2.0/lib/syntax_tree/cli.rb:136:in `run'
~/.asdf/installs/ruby/3.2.0/lib/ruby/gems/3.2.0/gems/syntax_tree-6.2.0/lib/syntax_tree/cli.rb:671:in `block (2 levels) in process_queue'
The listed files did not match the expected format.

$ ruby foo.rb

foo.rb: --> foo.rb
no anonymous block parameter
  1  def foo
> 2    bar(&)
  3  end
foo.rb:2: no anonymous block parameter (SyntaxError)

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