steep icon indicating copy to clipboard operation
steep copied to clipboard

Error: Unexpected node: s(:restarg, _args@1)

Open denisdefreyne opened this issue 8 years ago • 2 comments

steep check can raise #<RuntimeError: Unexpected node: s(:restarg, _args@1), 2> when using splat args.

Steps to reproduce

Create a file called x.rb:

class Hi
  def method_missing(*_args)
    self
  end
end

Run steep check x.rb:

#<RuntimeError: Unexpected node: s(:restarg, _args@1), 2>
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/type_construction.rb:598:in `synthesize'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/type_construction.rb:301:in `block in synthesize'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/type_construction.rb:737:in `block in each_child_node'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/type_construction.rb:735:in `each'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/type_construction.rb:735:in `each_child_node'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/type_construction.rb:300:in `synthesize'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/type_construction.rb:443:in `block in synthesize'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/type_construction.rb:442:in `tap'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/type_construction.rb:442:in `synthesize'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/drivers/check.rb:65:in `block in run'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/drivers/check.rb:44:in `each'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/drivers/check.rb:44:in `run'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/cli.rb:76:in `process_check'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/lib/steep/cli.rb:41:in `run'
  /usr/local/lib/ruby/gems/2.4.0/gems/steep-0.1.0.pre/exe/steep:11:in `<top (required)>'
  /usr/local/bin/steep:23:in `load'
  /usr/local/bin/steep:23:in `<main>'

denisdefreyne avatar Oct 03 '17 09:10 denisdefreyne

Thanks for reporting and sorry for late reply. I will write some code to prevent type checking from the crash.

soutaro avatar Oct 12 '17 14:10 soutaro

It doesn't seem to be reproduced this problem now, so I think we can close this issue. https://github.com/meganemura/steep-sandbox/tree/master/issue-7

$ bundle exec steep version
0.17.1
$ bundle exec steep check --log-level=info
[Steep 0.17.1] [target=issue] Adding source file: reproduce1.rb
[Steep 0.17.1] [target=issue] Adding signature file: sig/reproduce1.rbs
[Steep 0.17.1] [target=issue] [target#type_check(target_sources: [reproduce1.rb], validate_signatures: true)] type checking 1 files took 0.001234 seconds
[Steep 0.17.1] [target=issue] [target#type_check(target_sources: [reproduce1.rb], validate_signatures: true)] load signature and type check took 6.453435 seconds
[Steep 0.17.1] No type error found

meganemura avatar Jul 05 '20 16:07 meganemura