# \[Feature:1.9\] improvement of method redefinition warning

**URL:** <https://www.ruby-forum.com/t/feature-1-9-improvement-of-method-redefinition-warning/176330>\
**Category:** Development\
**Created:** [September 29, 2009, 9:06am UTC](https://www.ruby-forum.com/t/feature-1-9-improvement-of-method-redefinition-warning/176330 "2009-09-29T09:06:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [September 29, 2009, 9:06am UTC](https://www.ruby-forum.com/t/feature-1-9-improvement-of-method-redefinition-warning/176330/1 "2009-09-29T09:06:15Z")

</div>

e$B$J$+$@$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)

- assert\_match(/:#{line-1}: warning: previous definition of foo/,  
stderr)

- assert\_match(/:#{line-1}: warning: previous definition of foo/,  
stderr)

- assert\_match(/:#{line-1}: warning: previous definition of foo/,  
stderr)

---

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [September 30, 2009, 1:04am UTC](https://www.ruby-forum.com/t/feature-1-9-improvement-of-method-redefinition-warning/176330/2 "2009-09-30T01:04:11Z")

</div>

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.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [September 30, 2009, 6:18am UTC](https://www.ruby-forum.com/t/feature-1-9-improvement-of-method-redefinition-warning/176330/3 "2009-09-30T06:18:01Z")

</div>

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](http://redmine.ruby-lang.org/issues/show/2155)
