Project

General

Profile

Actions

Bug #11976

closed

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

Added by sergeim (Sergei Matheson) about 8 years ago. Updated almost 8 years ago.

Status:
Closed
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.
Actions

Also available in: Atom PDF

Like0
Like0Like0