Project

General

Profile

Actions

Bug #6454

closed

Anonymous classes should delete tmp_classpath on dup

Added by tenderlovemaking (Aaron Patterson) almost 12 years ago. Updated almost 12 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-05-19 trunk 35705) [x86_64-darwin11.4.0]
Backport:
[ruby-core:45132]

Description

When an anonymous class is duped, it should delete tmp_classpath from the iv table so that subsequent calls to inspect on the duped class will have different results.

I've attached a test case to demonstrate the problem.


Files

bad_inspect.patch (508 Bytes) bad_inspect.patch tenderlovemaking (Aaron Patterson), 05/19/2012 07:19 AM
rb_mod_init_copy.bug6454.patch (1.36 KB) rb_mod_init_copy.bug6454.patch drbrain (Eric Hodel), 05/19/2012 08:56 AM
noname (500 Bytes) noname Anonymous, 05/22/2012 12:53 AM

Updated by drbrain (Eric Hodel) almost 12 years ago

This patch fixes the name of dup'd anonymous classes (and modules).

Updated by mame (Yusuke Endoh) almost 12 years ago

  • Status changed from Open to Assigned
  • Assignee set to matz (Yukihiro Matsumoto)

Aaron, you'd better think we are really lazy :-)
It would be good not only to attach a demonstration patch but also
to write the demonstration in the mail.

x = Class.new
y = x.dup
p x #=> #Class:0x9a96ce0
p y #=> #Class:0x9a96cb8 # they are different as expected,

x = Class.new
x.inspect # but if #inspect is called before #dup,
y = x.dup
p x #=> #Class:0x9113c7c
p y #=> #Class:0x9113c7c # they become same.

I give +1 to drbrain's patch.

--
Yusuke Endoh

Updated by Anonymous almost 12 years ago

On Mon, May 21, 2012 at 08:20:48PM +0900, mame (Yusuke Endoh) wrote:

Issue #6454 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to matz (Yukihiro Matsumoto)

Aaron, you'd better think we are really lazy :-)

Haha! Sorry about that. I am also really lazy!

It would be good not only to attach a demonstration patch but also
to write the demonstration in the mail.

I will try to be less lazy next time. :-)

--
Aaron Patterson
http://tenderlovemaking.com/

Updated by matz (Yukihiro Matsumoto) almost 12 years ago

  • Assignee changed from matz (Yukihiro Matsumoto) to drbrain (Eric Hodel)

Commit the patch.

Matz.

Actions #5

Updated by drbrain (Eric Hodel) almost 12 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r35759.
Aaron, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • class.c (rb_mod_init_copy): Clear the cached inspect string of a
    dup'd anonymous module or class. [ruby-trunk - Bug #6454]
  • test/ruby/test_module.rb (class TestModule): ditto
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0