[ruby-core:73915] [Ruby trunk Bug#12098] Accessing a two level hash with invalid keys ignores the right side of expression

From: michel.boaventura@...
Date: 2016-02-22 00:34:12 UTC
List: ruby-core #73915
Issue #12098 has been reported by Michel Boaventura.

----------------------------------------
Bug #12098: Accessing a two level hash with invalid keys ignores the right side of expression
https://bugs.ruby-lang.org/issues/12098

* Author: Michel Boaventura
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Ruby 2.3 has a strange issue with hashes:

On Ruby 2.2:

~~~
irb(main):001:0> foo = {}
=> {}
irb(main):002:0> foo[:bla][:ble] = anything really
NameError: undefined local variable or method `really' for main:Object
        from (irb):2
~~~

On Ruby 2.3:

~~~
irb(main):001:0> foo = {}
=> {}
irb(main):002:0> foo[:bla][:ble] = anything really
=> nil
~~~

But:

~~~
irb(main):001:0> foo = {}
=> {}
irb(main):002:0> foo[:bar] = anything really
NameError: undefined local variable or method `really' for main:Object
        from (irb):2
~~~

You can put anything which is syntactically valid on the right side and ruby 2.3 will happily ignores it.




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

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next