[#65451] [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string — ko1@...

Issue #10333 has been updated by Koichi Sasada.

9 messages 2014/10/07

[ruby-core:65488] [ruby-trunk - Bug #9622] Extra method arguments are magically swallowed after first successful call, possible method cache bug

From: ruby-core@...
Date: 2014-10-07 19:56:39 UTC
List: ruby-core #65488
Issue #9622 has been updated by Marc-Andre Lafortune.

Duplicated by Bug #10291: Strange behaviour of splat in Ruby 2.0.0 added

----------------------------------------
Bug #9622: Extra method arguments are magically swallowed after first successful call, possible method cache bug
https://bugs.ruby-lang.org/issues/9622#change-49266

* Author: Jean Boussier
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: core
* Target version: 
* ruby -v: 2.0.0
* Backport: 1.9.3: REQUIRED, 2.0.0: DONE, 2.1: DONE
----------------------------------------
The following code behaviour totally change since ruby 2.0.0

~~~
class Foo

  def bar(*args)
    attribute(:bar, *args)
  end

  def attribute(name)
    puts name
  end

end

foo = Foo.new

begin
  foo.bar(100)
rescue => e
  puts e.class.name
end

foo.bar # legit

5.times do
  foo.bar(100)
end

puts 'No errors??? WTF???'

~~~


ruby < 2.0 output:

~~~
ArgumentError
bar
(eval):3:in `attribute': wrong number of arguments (2 for 1) (ArgumentError)
    from (eval):3:in `bar'
    from foo.rb:28
    from foo.rb:27:in `times'
    from foo.rb:27
~~~

Which is expected.

But ruby >= 2.0 output

~~~
ArgumentError
bar
bar
bar
bar
bar
bar
No errors??? WTF???
~~~

In short, after the first successful call, the extra arguments are just ignored. I have no idea of what is going on here, but it look like a broken optimization. 

All rubies >= 2.0 are affected. 1.8.7 and 1.9.3 are fine.


Regards.

A gist describing the issue: https://gist.github.com/byroot/9495455




-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next