Project

General

Profile

Actions

Bug #12098

closed

Accessing a two level hash with invalid keys ignores the right side of expression

Added by michel.boaventura (Michel Boaventura) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
[ruby-core:73915]

Description

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.

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Status changed from Open to Closed
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED

Fixed by r53485.

Updated by michel.boaventura (Michel Boaventura) over 8 years ago

Nobuyoshi Nakada wrote:

Fixed by r53485.

Thank you! I should have tested against master. Sorry about that :)

Updated by naruse (Yui NARUSE) over 8 years ago

  • Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONE
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0