# \[Bug:trunk\] cannot call public'ed method via public\_method

**URL:** <https://www.ruby-forum.com/t/bug-trunk-cannot-call-publiced-method-via-public-method/179413>\
**Category:** Development\
**Created:** [November 24, 2009, 2:42pm UTC](https://www.ruby-forum.com/t/bug-trunk-cannot-call-publiced-method-via-public-method/179413 "2009-11-24T14:42:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yusuke\_ENDOH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/c89c15/32.png) [@Yusuke\_ENDOH](https://www.ruby-forum.com/u/Yusuke_ENDOH)\
**Post date:** [November 24, 2009, 2:42pm UTC](https://www.ruby-forum.com/t/bug-trunk-cannot-call-publiced-method-via-public-method/179413/1 "2009-11-24T14:42:39Z")

</div>

e$B1sF#$G$9!#e(B

e$B7Q\>5@h$N%/%i%9$Ge(B public e$B$K$7$?%a%=%C%I$re(B public\_method  
e$B$G\<h$j=P$7$Fe(B  
e$B8F$S=P$9$He(B undefined private method e$B$H8@$o$l$F$7$^$$$^$9!#e(B

class C  
def foo; “FOO”; end  
private :foo  
end  
class D \< C  
public :foo  
end  
p D.new.public\_method(:foo).call  
#=\> undefined private method `foo' for class`D’ (NameError)

e$B$3$l$O8F$S=P$;$k$N$,@52r$H$$$&$3$H$G$$$$$G$7$g$&$+!#e(B

# Index: proc.c

— proc.c (revision 25895)  
+++ proc.c (working copy)  
@@ -894,6 +894,7 @@  
struct METHOD \*data;  
rb\_method\_entry\_t \*me, meb;  
rb\_method\_definition\_t \*def = 0;

- rb\_method\_flag\_t flag = NOEX\_UNDEF;

again:  
me = rb\_method\_entry(klass, id);  
@@ -921,8 +922,11 @@  
rb\_print\_undef(klass, id, 0);  
}  
def = me-\>def;

- if (scope && (me-\>flag & NOEX\_MASK) != NOEX\_PUBLIC) {
- rb\_print\_undef(rclass, def-\>original\_id, (int)(me-\>flag &  
NOEX\_MASK));

- if (flag == NOEX\_UNDEF) {
- flag = me-\>flag;
- if (scope && (flag & NOEX\_MASK) != NOEX\_PUBLIC) {
- 

```
 rb_print_undef(rclass, def->original_id, (int)(flag & 

```

NOEX\_MASK));

- }  
}  
if (def && def-\>type == VM\_METHOD\_TYPE\_ZSUPER) {  
klass = RCLASS\_SUPER(me-\>klass);

---

<div class="post-metadata">

**Author:** ![Yusuke\_ENDOH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/c89c15/32.png) [@Yusuke\_ENDOH](https://www.ruby-forum.com/u/Yusuke_ENDOH)\
**Post date:** [January 8, 2010, 3:47pm UTC](https://www.ruby-forum.com/t/bug-trunk-cannot-call-publiced-method-via-public-method/179413/2 "2010-01-08T15:47:39Z")

</div>

e$B%A%1%C%He(B #2397 e$B$,99?7$5$l$^$7$?!#e(B (by Yusuke E.)

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

This issue was solved with changeset r26256.  
Yusuke, 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/2397](http://redmine.ruby-lang.org/issues/show/2397)
