typeprof --version fails on non-CRuby
eregon opened this issue · 3 comments
For example on TruffleRuby:
$ typeprof --version
Currently, TypeProf can work on a Ruby implementation that supports RubyVM::InstructionSequence, such as CRuby.
zsh: exit 1 typeprof --version
If none of typeprof can work on non-CRuby I guess that makes sense, but still shouldn't --version
and maybe also --help
still work, and only fail when actually needing RubyVM::InstructionSequence
?
I think that's what most libraries do and I think it's closer to expected behavior.
Context: I'm updating TruffleRuby to Ruby 3 compatibility.
Another option would be to not include typeprof on TruffleRuby/non-CRuby but I think that's bad because suddenly there would be some expected bundled gem missing, bundle install
might fail if typeprof
is in it, etc.
If I remove
Lines 1 to 4 in 02b76ae
I think it's much better to fail later here.
RubyVM is only used in 4 places (0.12.0), so I'd suggest to move the check there, just before the actual usages:
$ ack RubyVM lib/gems/gems/typeprof-0.12.0/lib
lib/gems/gems/typeprof-0.12.0/lib/typeprof.rb
1:unless defined?(RubyVM::InstructionSequence)
2: puts "Currently, TypeProf can work on a Ruby implementation that supports RubyVM::InstructionSequence, such as CRuby."
lib/gems/gems/typeprof-0.12.0/lib/typeprof/iseq.rb
6: opt = RubyVM::InstructionSequence.compile_option
12: new(RubyVM::InstructionSequence.compile_file(file, **opt).to_a)
16: opt = RubyVM::InstructionSequence.compile_option
22: new(RubyVM::InstructionSequence.compile(str, path, **opt).to_a)
Thanks! It looks reasonable. I'll do later