Project

General

Profile

Actions

Bug #11976

closed

Assigning to nil as a hash short-circuits without error.

Added by sergeim (Sergei Matheson) over 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin14]
[ruby-core:72804]

Description

When assigning to nil as a hash, the RHS gets short-circuited, and the hash assignment on nil returns nil.
To reproduce:

nil[:some_key] = undefined_method
# Expected: NameError: undefined local variable or method `undefined_method' for main:Object
# Actual: evaluates to nil. No errors raised.

Updated by nobu (Nobuyoshi Nakada) over 6 years ago

  • Description updated (diff)
  • 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 at r53485.

Updated by naruse (Yui NARUSE) about 6 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

ruby_2_3 r54396 merged revision(s) 53485.

Actions

Also available in: Atom PDF