From: "tadf (tadayoshi funaba)" Date: 2012-06-03T19:29:41+09:00 Subject: [ruby-core:45403] [ruby-trunk - Bug #6538] Mutability of Rational and Complex Issue #6538 has been updated by tadf (tadayoshi funaba). Assignee set to tadf (tadayoshi funaba) class IM def initialize(s) @s = s end attr :s end i = IM.new(1) i.s #=> 1 i.instance_eval{@s = 100} i.s #=> 100 is this a mutable? ---------------------------------------- Bug #6538: Mutability of Rational and Complex https://bugs.ruby-lang.org/issues/6538#change-26990 Author: marcandre (Marc-Andre Lafortune) Status: Open Priority: Low Assignee: tadf (tadayoshi funaba) Category: core Target version: ruby -v: r35875 I hesitated to report this, but there is a "hole" in the immutability of Rational & Complex: r = Rational(0) # Rationals are immutable r.freeze # but let's be certain and freeze it! magic_trick(r) # r is now changed: r # => (1/42) The same thing occurs with Complex. I've left out the definition of `magic_trick` for anyone who wants to try and figure it out, but it's here: http://pastie.org/4016117 Is this worth fixing? -- http://bugs.ruby-lang.org/