Skip to content

crash parser when defining method inside block #13

@riffraff

Description

@riffraff

Reproductible with

$ cat c.rb 

class C

  send :each do
    def foo
    end 
  end

end
$ laser -d c.rb 
{:fix=>false, :display=>true, :"report-fixed"=>false, :"line-length"=>nil, :only=>nil, :stdin=>false, :"list-modules"=>false, :profile=>false, :debug=>true, :inline_comment_space=>2, :help=>false, :debug_given=>true}
/Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:182:in `build_formal_args': undefined method `is_block?' for nil:NilClass (NoMethodError)
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:904:in `block (3 levels) in walk_block_body'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:80:in `with_self'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:903:in `block (2 levels) in walk_block_body'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:276:in `with_current_basic_block'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:901:in `block in walk_block_body'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:803:in `with_jump_targets'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:900:in `walk_block_body'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:854:in `call_with_explicit_block'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:877:in `call_method_with_block'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:406:in `block in walk_node'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:284:in `with_current_node'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:291:in `walk_node'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:817:in `walk_body'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:1074:in `block in walk_body_with_rescue_target'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:803:in `with_jump_targets'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:1072:in `walk_body_with_rescue_target'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:1055:in `bodystmt_walk'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:294:in `block in walk_node'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:284:in `with_current_node'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:291:in `walk_node'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:1325:in `block (2 levels) in module_eval_instruct'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:80:in `with_self'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:1324:in `block in module_eval_instruct'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:59:in `with_scope'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:1323:in `module_eval_instruct'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:1251:in `class_instruct'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:297:in `block in walk_node'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:284:in `with_current_node'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:291:in `walk_node'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:822:in `block in walk_body'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:822:in `each'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:822:in `walk_body'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:437:in `block in walk_node'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:284:in `with_current_node'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:291:in `walk_node'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/cfg_builder.rb:28:in `build'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow.rb:22:in `perform_cfg_analysis'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/annotations.rb:43:in `block in perform_load_time_analysis'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/annotations.rb:38:in `each'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/annotations.rb:38:in `perform_load_time_analysis'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/annotations.rb:15:in `annotate_inputs'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/sexp_analysis.rb:10:in `analyze_inputs'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/sexp_analysis.rb:21:in `parse'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/analysis/sexp_analysis.rb:32:in `find_sexps'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/warnings/assignment_in_condition.rb:8:in `match?'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/warning.rb:93:in `generated_warnings'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/scanner.rb:166:in `block in scan_for_warnings'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/scanner.rb:166:in `map'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/scanner.rb:166:in `scan_for_warnings'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/scanner.rb:138:in `scan_for_file_warnings'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/scanner.rb:46:in `scan'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/runner.rb:161:in `block in collect_warnings'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/runner.rb:156:in `map'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/runner.rb:156:in `collect_warnings'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/lib/laser/runner.rb:18:in `run'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/gems/laser-0.7.0.pre2/bin/laser:7:in `<top (required)>'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/bin/laser:19:in `load'
    from /Users/riffraff/.rvm/gems/ruby-1.9.2-p180/bin/laser:19:in `<main>'

ruby: ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.4]
box: macbook pro osx snow leopard
laser: gem install laser --prerelease

This is basically the standard pattern to define a method on the association proxies in rails so it's a relatively useful feature to support, hope this helps to diagnose, and if needed I can do more tests and provide more details

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions