https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112012-03-11T17:12:34ZRuby Issue Tracking SystemRuby master - Bug #5828: Non anonymous classes can't be frozen, cloned and then inspectedhttps://bugs.ruby-lang.org/issues/5828?journal_id=244792012-03-11T17:12:34Zko1 (Koichi Sasada)
<ul><li><strong>Assignee</strong> set to <i>akr (Akira Tanaka)</i></li></ul><p>Tanaka-san says he found the reason of this issue.</p> Ruby master - Bug #5828: Non anonymous classes can't be frozen, cloned and then inspectedhttps://bugs.ruby-lang.org/issues/5828?journal_id=248092012-03-18T18:46:09Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li></ul> Ruby master - Bug #5828: Non anonymous classes can't be frozen, cloned and then inspectedhttps://bugs.ruby-lang.org/issues/5828?journal_id=465682014-05-06T13:50:23Zakr (Akira Tanaka)akr@fsij.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Feedback</i></li></ul><p>The name of anonymous class is searched and cached when it is first inspected.<br>
The cache is implemented as a hidden instance variable of the class.<br>
If the class is frozen, the cache is failed as the exception because the instance variable is not assignable.</p>
<p>Note that Class.new.freeze.to_s doesn't raise the exception.<br>
This is because Kernel#freeze is redefined by Module#freeze and it caches the class name before freezing.</p>
<p>Kernel#clone is not redefined.<br>
So there is not such trick to avoid the exception.</p>
<p>I'm not sure that it is worth to fix this problem.</p> Ruby master - Bug #5828: Non anonymous classes can't be frozen, cloned and then inspectedhttps://bugs.ruby-lang.org/issues/5828?journal_id=465792014-05-06T23:01:44Zagrimm (Andrew Grimm)andrew.j.grimm@gmail.com
<ul></ul><p>I'm happy for this bug to be closed, as I don't have a need to freeze and clone a class.</p> Ruby master - Bug #5828: Non anonymous classes can't be frozen, cloned and then inspectedhttps://bugs.ruby-lang.org/issues/5828?journal_id=470682014-06-07T02:41:14Zakr (Akira Tanaka)akr@fsij.org
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>Applied in changeset r46370.</p>
<hr>
<ul>
<li>object.c (rb_mod_initialize_clone): Override Kernel#initialize_clone<br>
to avoid an exception on Class.new.freeze.clone.to_s.<br>
Reported by Andrew Grimm. <a href="/issues/5828">[ruby-core:41858]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Non anonymous classes can't be frozen, cloned and then inspected (Closed)" href="https://bugs.ruby-lang.org/issues/5828">#5828</a>]</li>
</ul> Ruby master - Bug #5828: Non anonymous classes can't be frozen, cloned and then inspectedhttps://bugs.ruby-lang.org/issues/5828?journal_id=470692014-06-07T02:49:20Zakr (Akira Tanaka)akr@fsij.org
<ul></ul><p>I decided to fix this problem because to_s method is useful for debugging and exception on to_s can be<br>
irritating.</p>