Skip to content

Commit

Permalink
Fixed bug where inheritable_accessor and Symbol value raised TypeErro…
Browse files Browse the repository at this point in the history
…r(can't dup Symbol)
  • Loading branch information
fabien committed Jan 10, 2009
1 parent c0ea02c commit f3f6c59
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/extlib/class.rb
Expand Up @@ -118,7 +118,7 @@ def self.#{ivar}
return @#{ivar} if self.object_id == #{self.object_id} || defined?(@#{ivar})
ivar = superclass.#{ivar}
return nil if ivar.nil? && !#{self}.instance_variable_defined?("@#{ivar}")
@#{ivar} = ivar && !ivar.is_a?(Module) && !ivar.is_a?(Numeric) && !ivar.is_a?(TrueClass) && !ivar.is_a?(FalseClass) ? ivar.dup : ivar
@#{ivar} = ivar && !ivar.is_a?(Module) && !ivar.is_a?(Numeric) && !ivar.is_a?(TrueClass) && !ivar.is_a?(FalseClass) && !ivar.is_a?(Symbol) ? ivar.dup : ivar
end
RUBY
unless instance_reader == false
Expand Down
16 changes: 16 additions & 0 deletions spec/class_spec.rb
Expand Up @@ -18,6 +18,14 @@ class Grandparent
self._attribute = 1900
end

class ClassWithInheritableSymbolAccessor
class_inheritable_accessor :symbol
self.symbol = :foo
end

class ClassInheritingSymbolAccessor < ClassWithInheritableSymbolAccessor
end

describe Class, "#inheritable_accessor" do

after :each do
Expand Down Expand Up @@ -104,6 +112,14 @@ class Grandparent

end

describe Class, "#inheritable_accessor (of type Symbol)" do

it "should not raise" do
lambda { ClassInheritingSymbolAccessor.symbol }.should_not raise_error(TypeError)
end

end

#
# The bug that prompted this estoric spec was found in
# the wild when using dm-is-versioned with c_i_w.
Expand Down

0 comments on commit f3f6c59

Please sign in to comment.