Actions
Bug #18389
closed`binding.irb` can fail in some classes that implement `context` and `print` methods.
Description
class Foo
def boop
binding.irb
end
def context
end
def print
end
end
Foo.new.boop
It fails with:
> ruby ./test.rb
From: ./test.rb @ line 3 :
1: class Foo
2: def boop
=> 3: binding.irb
4: end
5:
6: def context
7: end
8:
./test.rb:9:in `print': wrong number of arguments (given 1, expected 0) (ArgumentError)
from /Users/samuel/.gem/ruby/3.0.3/gems/irb-1.3.7/lib/irb/extend-command.rb:238:in `install_alias_method'
from /Users/samuel/.gem/ruby/3.0.3/gems/irb-1.3.7/lib/irb/extend-command.rb:252:in `block in extend_object'
from /Users/samuel/.gem/ruby/3.0.3/gems/irb-1.3.7/lib/irb/extend-command.rb:251:in `each'
from /Users/samuel/.gem/ruby/3.0.3/gems/irb-1.3.7/lib/irb/extend-command.rb:251:in `extend_object'
from /Users/samuel/.gem/ruby/3.0.3/gems/irb-1.3.7/lib/irb.rb:466:in `extend'
from /Users/samuel/.gem/ruby/3.0.3/gems/irb-1.3.7/lib/irb.rb:466:in `initialize'
from /Users/samuel/.gem/ruby/3.0.3/gems/irb-1.3.7/lib/irb.rb:959:in `new'
from /Users/samuel/.gem/ruby/3.0.3/gems/irb-1.3.7/lib/irb.rb:959:in `irb'
from <internal:prelude>:5:in `irb'
from ./test.rb:3:in `boop'
from ./test.rb:13:in `<main>'
I suggest that binding.irb
should be a little bit less invasive to avoid these kinds of issues.
Updated by ioquatix (Samuel Williams) about 3 years ago
- Description updated (diff)
Updated by jeremyevans0 (Jeremy Evans) almost 3 years ago
I've submitted a pull request to fix this error: https://github.com/ruby/irb/pull/325
Updated by osyo (manga osyo) almost 3 years ago
- Status changed from Open to Closed
Applied in changeset git|b6b2e489f10bfc771beae8fa0ee5237613acd18f.
[ruby/irb] Changed to call Kernel.print
If you call binding.irb
on a class defined #print
, it will crash, so call Kernel.print
.
Fix [Bug #18389] binding.irb
can fail in some classes that implement context
and print
methods.
Actions
Like0
Like0Like0Like0