# \[Bug:trunk\] NoMethodError message "no superclass method"

**URL:** <https://www.ruby-forum.com/t/bug-trunk-nomethoderror-message-no-superclass-method/178171>\
**Category:** Development\
**Created:** [October 30, 2009, 4:44am UTC](https://www.ruby-forum.com/t/bug-trunk-nomethoderror-message-no-superclass-method/178171 "2009-10-30T04:44:30Z")\
**Posts on this page:** 2\
**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:** [October 30, 2009, 4:44am UTC](https://www.ruby-forum.com/t/bug-trunk-nomethoderror-message-no-superclass-method/178171/1 "2009-10-30T04:44:30Z")

</div>

e$B$J$+$@$G$9!#e(B

trunke$B$GAH$_9~$_$N%a%=%C%I$+$i$Ne(BNoMethodErrore$B$N%a%C%;!\<%8$,e(B"no  
superclass method"e$B$K$J$j$^$;$s!#e(B

$ ./ruby -v -e ‘module Enumerable;undef min;end; (1…2).min{}’  
ruby 1.9.2dev (2009-10-30 trunk 25565) [universal.x86\_64-darwin9.0]  
-e:1:in `min': undefined method`min’ for 1…2:Range (NoMethodError)  
from -e:1:in `’

e$B0lJ}!"e(B\_\_send\_\_e$B$r;H$&$He(Bsupere$B$H$OL54X78$J$N$K=P$F$7$^$$$^$9!#e(B

$ ./ruby -e ‘Object.new.method(: **send** ).call(:foo)’  
-e:1:in `call': super: no superclass method`foo’ for  
#Object:0x000001002f93f0 (NoMethodError)  
from -e:1:in `’

e$B$7$+$b!"$b$&0lEYF1$8%a%=%C%I$r8F$V$HFs2sL$K$O=P$^$;$s!#e(B

$ ./ruby -e ‘2.times{begin Object.new.method(: **send** ).call(:foo);  
rescue NoMethodError =\> e; puts e.message; end}’  
super: no superclass method `foo' for #<Object:0x000001002e2f10> undefined method`foo’ for #Object:0x000001002e2c68

# Index: vm\_eval.c

— vm\_eval.c (revision 25565)  
+++ vm\_eval.c (working copy)  
@@ -22,5 +22,4 @@ static VALUE vm\_exec(rb\_thread\_t \*th);  
static void vm\_set\_eval\_stack(rb\_thread\_t \* th, VALUE iseqval, const  
NODE \*cref);  
static int vm\_collect\_local\_variables\_in\_heap(rb\_thread\_t \*th, VALUE  
\*dfp, VALUE ary);  
-static VALUE send\_internal(int argc, const VALUE \*argv, VALUE recv, int  
scope);

typedef enum call\_type {  
@@ -30,4 +29,6 @@ typedef enum call\_type {  
} call\_type;

+static VALUE send\_internal(int argc, const VALUE _argv, VALUE recv,  
call\_type scope);  
+  
static inline VALUE  
vm\_call0(rb\_thread\_t_ th, VALUE recv, VALUE id, int argc, const VALUE  
_argv,  
@@ -105,5 +106,5 @@ vm\_call0(rb\_thread\_t_ th, VALUE recv, VA  
klass = RCLASS\_SUPER(klass);  
if (!klass || !(me = rb\_method\_entry(klass, id))) {

- 

```
 return method_missing(recv, id, argc, argv, 0);

```

- 

```
 return method_missing(recv, id, argc, argv, NOEX_SUPER);

```

}  
RUBY\_VM\_CHECK\_INTS();  
@@ -122,5 +123,5 @@ vm\_call0(rb\_thread\_t\* th, VALUE recv, VA  
switch (def-\>body.optimize\_type) {  
case OPTIMIZED\_METHOD\_TYPE\_SEND:

- 

```
 val = send_internal(argc, argv, recv, NOEX_NOSUPER | 

```

NOEX\_PRIVATE);

- 

```
 val = send_internal(argc, argv, recv, CALL_FCALL);
 break;

```

case OPTIMIZED\_METHOD\_TYPE\_CALL: {  
@@ -176,5 +177,5 @@ vm\_call\_super(rb\_thread\_t \*th, int argc,  
me = rb\_method\_entry(klass, id);  
if (!me) {

- return method\_missing(recv, id, argc, argv, 0);

- return method\_missing(recv, id, argc, argv, NOEX\_SUPER);  
}

@@ -220,5 +221,4 @@ rb\_call0(VALUE recv, ID mid, int argc, c  
VALUE klass = CLASS\_OF(recv);  
rb\_method\_entry\_t \*me;

- struct cache\_entry \*ent;  
rb\_thread\_t \*th = GET\_THREAD();  
ID oid;  
@@ -234,26 +234,10 @@ rb\_call0(VALUE recv, ID mid, int argc, c  
}

- /\* is it in the method cache? \*/

- ent = cache + EXPR1(klass, mid);

- 
- if (ent-\>mid == mid && ent-\>klass == klass) {

- me = ent-\>me;

- if (UNDEFINED\_METHOD\_ENTRY\_P(me)) {

- 

```
 return method_missing(recv, mid, argc, argv,

```

- 

```
     scope == CALL_VCALL ? NOEX_VCALL : 0);

```

- }

- klass = me-\>klass;

- }

- else if ((me = rb\_method\_entry\_without\_cache(klass, mid)) != 0 &&  
me-\>def) {

- klass = me-\>klass;

- }

- else {

- if (scope == 3) {

- 

```
 return method_missing(recv, mid, argc, argv, NOEX_SUPER);

```

- }

- me = rb\_method\_entry(klass, mid);
- if (UNDEFINED\_METHOD\_ENTRY\_P(me)) {  
return method\_missing(recv, mid, argc, argv,  
scope == CALL\_VCALL ? NOEX\_VCALL : 0);  
}

- 

- klass = me-\>klass;  
oid = me-\>def-\>original\_id;  
noex = me-\>flag;  
@@ -580,5 +564,5 @@ rb\_funcall\_no\_recursive(VALUE obj, ID id

static VALUE  
-send\_internal(int argc, const VALUE \*argv, VALUE recv, int scope)  
+send\_internal(int argc, const VALUE \*argv, VALUE recv, call\_type scope)  
{  
VALUE vid;  
@@ -617,5 +601,5 @@ VALUE  
rb\_f\_send(int argc, VALUE \*argv, VALUE recv)  
{

- return send\_internal(argc, argv, recv, NOEX\_NOSUPER |  
NOEX\_PRIVATE);

- return send\_internal(argc, argv, recv, CALL\_FCALL);  
}

@@ -634,5 +618,5 @@ VALUE  
rb\_f\_public\_send(int argc, VALUE \*argv, VALUE recv)  
{

- return send\_internal(argc, argv, recv, NOEX\_PUBLIC);

- return send\_internal(argc, argv, recv, CALL\_PUBLIC);  
}

# Index: test/ruby/test\_object.rb

— test/ruby/test\_object.rb (revision 25565)  
+++ test/ruby/test\_object.rb (working copy)  
@@ -378,4 +378,25 @@ class TestObject \< Test::Unit::TestCase  
end

- def test\_no\_superclass\_method
- o = Object.new
- e = assert\_raise(NoMethodError) {
- 

o.method(: **send** ).call(:never\_defined\_test\_no\_superclass\_method)

- }
- m1 = e.message
- assert\_no\_match(/no superclass method/, m1)
- e = assert\_raise(NoMethodError) {
- 

o.method(: **send** ).call(:never\_defined\_test\_no\_superclass\_method)

- }
- assert\_equal(m1, e.message)
- e = assert\_raise(NoMethodError) {
- 

```
 o.never_defined_test_no_superclass_method

```

- }
- assert\_equal(m1, e.message)
- end
- 
- def test\_superclass\_method
- assert\_in\_out\_err(["-e", “module Enumerable;undef min;end;  
(1…2).min{}”], [], [], /no superclass method/)
- end
- def test\_specific\_eval\_with\_wrong\_arguments  
assert\_raise(ArgumentError) do

---

<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:** [October 30, 2009, 9:07am UTC](https://www.ruby-forum.com/t/bug-trunk-nomethoderror-message-no-superclass-method/178171/2 "2009-10-30T09:07:54Z")

</div>

e$B%A%1%C%He(B #2312 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

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

* * *

[http://redmine.ruby-lang.org/issues/show/2312](http://redmine.ruby-lang.org/issues/show/2312)
