Class vars defined in frozen module are modifiable when module is included 
---------------------------------------------------------------------------

                 Key: JRUBY-1364
                 URL: http://jira.codehaus.org/browse/JRUBY-1364
             Project: JRuby
          Issue Type: Bug
            Reporter: Bill Dortch
            Assignee: Thomas E Enebo
            Priority: Minor


I hesitate to file this as a bug, since JRuby's behavior matches MRI's, but I 
think both are wrong:
{noformat}
>> module M
>>   @@cvar = 1
>>   def self.inc
>>     @@cvar += 1
>>   end
>> end
=> nil
>> M.inc
=> 2
>> M.freeze  #=> freezing module here
=> M
>> M.inc
TypeError: can't modify frozen class/module#<Class:01x1a70b8>
        from (irb):9:in `binding'
>> class C
>>   include M
>>   def inc
>>     @@cvar += 1
>>   end
>> end
=> nil
>> C.new.inc
=> 3
>> C.new.inc
=> 4
>> C.freeze
=> C
>> C.new.inc
=> 5
>> M.send :class_variable_get, :@@cvar
=> 5
{noformat}
In JRuby, this happens because {{isFrozen()}} is called on the 
{{IncludedModuleWrapper}}, which does not pass the call through to the delegate 
(wrapped module).  I suspect MRI code does something similar.

So, is this "correct" behavior?  Fix or leave as is?


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to