Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: JRuby 1.6.7
-
Fix Version/s: None
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:Linux 3.0.0-16-generic #29-Ubuntu SMP Tue Feb 14 12:48:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
jruby 1.6.7 (ruby-1.9.2-p312) (2012-02-22 3e82bc8) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_26) [linux-amd64-java]
-
Number of attachments :
Description
The array returned by Module#constants should[1] have the most recently defined constant last but this is not the case.
module MyNamespace
class First
end
class Second
end
class Third
end
end
p MyNamespace.constants
# => [:Third, :Second, :First]
In this case they are in reverse order but that isn't always the case either.
[1] Not sure if I should be using the word "should", maybe this isn't behavior that one should rely on but that's how it has been on the standard interpreters for years.
A survey of popular interpreters shows that MRI does indeed maintain ordering, but other implementations do not. I am somewhat inclined to mark this WONT FIX because I don't feel the ordering is part of the API. This might be something to confirm with Matz; if he says it's part of the API, we'll do it. If not, we won't.