Issue #6067 has been updated by nahi (Hiroshi Nakamura).


Closing as a duplicate, since #5449 was confirmed as a bug by Matz. #5449 will fix it.
----------------------------------------
Bug #6067: Conditional assignment of a nested constant raises a SyntaxError
https://bugs.ruby-lang.org/issues/6067#change-28049

Author: brixen (Brian Ford)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: 
Target version: 
ruby -v: ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]


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


-- 
http://bugs.ruby-lang.org/