Project

General

Profile

Actions

Bug #12501

closed

Assignment to local variable itself doesn't occur an error

Added by scorix@gmail.com (Yu Zhang) almost 8 years ago. Updated almost 8 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:76064]

Description

For example:

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

but

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?

Updated by shevegen (Robert A. Heiler) almost 8 years ago

I think it is neither a feature nor a bug but simply a consequence of how the ruby parser (or was it
the lexer or scanner) reads/parses the code. The pickaxe mentioned that once, if I remember correctly.

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Description updated (diff)
  • Status changed from Open to Rejected
Actions

Also available in: Atom PDF

Like0
Like0Like0