michaeledgar/laser — Issue #17: Simulate_require fails to require if extension is given
Author: carl-ellis
Created: 2012-02-16 15:06:39+00:00
State: open

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 `'
from /usr/bin/laser:19:in `load'
from /usr/bin/laser:19:in `

'```

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.