[Feature:1.9] improvement of method redefinition warning

[email protected]$G$9!#e(B

e$B%a%=%C%I:FDj5A$G7Y9p$r=P$9$H$-$K!">e=q$-$5$l$k$[$&$NDj5A$N>l=j$be(B
e$B=P$7$F$O$I$&$G$7$g$&$+!#e(B

Index: proc.c

— proc.c (revision 25152)
+++ proc.c (working copy)
@@ -649,6 +649,8 @@ rb_proc_arity(VALUE self)
}

-static rb_iseq_t *
-get_proc_iseq(VALUE self, int *is_proc)
+#define get_proc_iseq rb_proc_get_iseq
+
+rb_iseq_t *
+rb_proc_get_iseq(VALUE self, int *is_proc)
{
rb_proc_t *proc;
Index: vm_method.c

— vm_method.c (revision 25152)
+++ vm_method.c (working copy)
@@ -189,5 +189,24 @@ rb_add_method_def(VALUE klass, ID mid, r
old_def->type != VM_METHOD_TYPE_UNDEF &&
old_def->type != VM_METHOD_TYPE_ZSUPER) {

  •  extern rb_iseq_t *rb_proc_get_iseq(VALUE proc, int *is_proc);
    
  •  rb_iseq_t *iseq = 0;
    
  •  rb_warning("method redefined; discarding old %s", 
    

rb_id2name(mid));

  •  switch (old_def->type) {
    
  •    case VM_METHOD_TYPE_ISEQ:
    
  • iseq = old_def->body.iseq;

  • break;

  •    case VM_METHOD_TYPE_BMETHOD:
    
  • iseq = rb_proc_get_iseq(old_def->body.proc, 0);

  • break;

  •    default:
    
  • break;

  •  }
    
  •  if (iseq && !NIL_P(iseq->filename)) {
    
  • int line = iseq->insn_info_table ? rb_iseq_first_lineno(iseq) : 0;

  • rb_compile_warning(RSTRING_PTR(iseq->filename), line,

  •       "previous definition of %s was here",
    
  •       rb_id2name(old_def->original_id));
    
  •  }
    

    }
    rb_free_method_entry(old_me);
    Index: test/ruby/test_class.rb
    ===================================================================
    — test/ruby/test_class.rb (revision 25152)
    +++ test/ruby/test_class.rb (working copy)
    @@ -115,4 +115,5 @@ class TestClass < Test::Unit::TestCase
    end
    assert_match(/:#{line}: warning: method redefined; discarding old
    foo/, stderr)

  • assert_match(/:#{line-1}: warning: previous definition of foo/,
    stderr)

    stderr = EnvUtil.verbose_warning do
    @@ -142,4 +143,5 @@ class TestClass < Test::Unit::TestCase
    end
    assert_match(/:#{line}: warning: method redefined; discarding old
    foo/, stderr)

  • assert_match(/:#{line-1}: warning: previous definition of foo/,
    stderr)

    stderr = EnvUtil.verbose_warning do
    Index: test/ruby/test_module.rb
    ===================================================================
    — test/ruby/test_module.rb (revision 25152)
    +++ test/ruby/test_module.rb (working copy)
    @@ -797,4 +797,5 @@ class TestModule < Test::Unit::TestCase
    end
    assert_match(/:#{line}: warning: method redefined; discarding old
    foo/, stderr)

  • assert_match(/:#{line-1}: warning: previous definition of foo/,
    stderr)

    stderr = EnvUtil.verbose_warning do
    @@ -824,4 +825,5 @@ class TestModule < Test::Unit::TestCase
    end
    assert_match(/:#{line}: warning: method redefined; discarding old
    foo/, stderr)

  • assert_match(/:#{line-1}: warning: previous definition of foo/,
    stderr)

    stderr = EnvUtil.verbose_warning do

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:39400] [Feature:1.9] improvement of method
redefinition warning”
on Tue, 29 Sep 2009 16:05:34 +0900, Nobuyoshi N.
[email protected] writes:

|e$B%a%=%C%I:FDj5A$G7Y9p$r=P$9$H$-$K!">e=q$-$5$l$k$[$&$NDj5A$N>l=j$be(B
|e$B=P$7$F$O$I$&$G$7$g$&$+!#e(B

e$B$$$$$s$8$c$J$$$G$7$g$&$+!#e(B

e$B%A%1%C%He(B #2155 e$B$,99?7$5$l$^$7$?!#e(B (by Nobuyoshi N.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

Applied in changeset r25169.

http://redmine.ruby-lang.org/issues/show/2155

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs