Issue #10557 has been updated by Koichi Sasada.

Assignee set to Koichi Sasada

This is an issue in compile.c (opt_aref_with). There is same issue on opt_aset_with, opt_str_freeze.


----------------------------------------
Bug #10557: Block not given when the argument is a string
https://bugs.ruby-lang.org/issues/10557#change-50216

* Author: Bartosz Kopinski
* Status: Open
* Priority: Urgent
* Assignee: Koichi Sasada
* Category: core
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0dev (2014-11-30 trunk 48655) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
This seems really weird and random. Can anyone else confirm it's bug?

```ruby
class Klass
  def [](_)
    block_given?
  end
end

# ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
Klass.new.[](nil){ }    # => true
Klass.new.[](0){ }      # => true
Klass.new.[](false){ }  # => true
Klass.new.[](''){ }     # => true

# ruby 2.2.0dev (2014-11-30 trunk 48655) [x86_64-darwin14]
Klass.new.[](nil){ }    # => true
Klass.new.[](0){ }      # => true
Klass.new.[](false){ }  # => true
Klass.new.[](''){ }     # => false
```



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