Project

General

Profile

Actions

Bug #6067

closed

Conditional assignment of a nested constant raises a SyntaxError

Added by brixen (Brian Shirai) about 12 years ago. Updated almost 12 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]
Backport:
[ruby-core:42826]

Description

I can conditionally assign a simple constant:

$ ruby -v -e 'p X ||= 1'
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]
1

However, conditional assignment of a nested constant raises a SyntaxError:

$ ruby -v -e 'module A; end; p A::X ||= 1'
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]
-e:1: constant re-assignment

But I can assign the constant unconditionally, of course:

$ ruby -v -e 'module A; end; p A::X = 1'
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]
1

Is this a bug?

Thanks,
Brian


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #5449: nested constant opasign not workingClosednobu (Nobuyoshi Nakada)10/15/2011Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0