[ruby-core:76068] [Ruby trunk Bug#12501][Rejected] Assignment to local variable itself doesn't occur an error

From: nobu@...
Date: 2016-06-17 23:15:49 UTC
List: ruby-core #76068
Issue #12501 has been updated by Nobuyoshi Nakada.

Description updated
Status changed from Open to Rejected

----------------------------------------
Bug #12501: Assignment to local variable itself doesn't occur an error
https://bugs.ruby-lang.org/issues/12501#change-59264

* Author: Yu Zhang
* Status: Rejected
* Priority: Normal
* Assignee: 
* ruby -v: 2.3.0
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
For example:

~~~ruby
a = b # => undefined local variable or method `b' for main:Object (NameError)
~~~

but

~~~ruby
a = a # => nil
a = a.merge({}) # => undefined method `merge' for nil:NilClass (NoMethodError)
~~~

The `a` after `=` is an undefined local variable, I think it should raise a `NameError`, but it only returns a nil value.

Is this a feature or bug?



-- 
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