Skip to content

Simulate_require fails to require if extension is given #17

@carl-ellis

Description

@carl-ellis

Using the test case:

a.rb:

class A
end 

b.rb:

require './a.rb'
class B
end

Then running:
laser b.rb

I get the following stack trace:
/usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/simulation.rb:369:in simulate_require': No such file: ./a.rb (LoadError)
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/simulation.rb:284:in simulate_special_method' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/simulation.rb:234:in simulate_call_dispatch'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/simulation.rb:199:in simulate_call' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/simulation.rb:190:in simulate_call_instruction'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/simulation.rb:160:in simulate_instruction' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/simulation.rb:112:in simulate_exit_instruction'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/simulation.rb:96:in simulate_block' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/simulation.rb:41:in block in simulate'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/simulation.rb:39:in loop' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/simulation.rb:39:in simulate'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow/control_flow_graph.rb:222:in analyze' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/control_flow.rb:23:in perform_cfg_analysis'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/annotations.rb:43:in block in perform_load_time_analysis' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/annotations.rb:38:in each'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/annotations.rb:38:in perform_load_time_analysis' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/annotations.rb:15:in annotate_inputs'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/sexp_analysis.rb:10:in analyze_inputs' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/sexp_analysis.rb:21:in parse'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/analysis/sexp_analysis.rb:32:in find_sexps' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/warnings/rescue_exception.rb:11:in match?'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/warning.rb:93:in generated_warnings' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/scanner.rb:166:in block in scan_for_warnings'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/scanner.rb:166:in map' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/scanner.rb:166:in scan_for_warnings'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/scanner.rb:138:in scan_for_file_warnings' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/scanner.rb:46:in scan'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/runner.rb:161:in block in collect_warnings' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/runner.rb:156:in map'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/runner.rb:156:in collect_warnings' from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/lib/laser/runner.rb:18:in run'
from /usr/lib/ruby/gems/1.9.1/gems/laser-0.7.0.pre2/bin/laser:7:in <top (required)>' from /usr/bin/laser:19:in load'
from /usr/bin/laser:19:in <main>'

Whereas if I remove the ".rb" from the require line this works. I've tracked the problem down to /lib/laser/analysis/control_flow/simulation.rb:357 where you assume the trailing ".rb" is never present.

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