Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
floehopper opened this issue Nov 12, 2024 · 0 comments

Comments

@floehopper
Copy link

floehopper commented Nov 12, 2024

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)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant