# Cannot eval in the binding that has a singleton method

**URL:** <https://www.ruby-forum.com/t/cannot-eval-in-the-binding-that-has-a-singleton-method/129004>\
**Category:** Development\
**Created:** [February 13, 2008, 2:12pm UTC](https://www.ruby-forum.com/t/cannot-eval-in-the-binding-that-has-a-singleton-method/129004 "2008-02-13T14:12:08Z")\
**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:** [February 13, 2008, 2:12pm UTC](https://www.ruby-forum.com/t/cannot-eval-in-the-binding-that-has-a-singleton-method/129004/1 "2008-02-13T14:12:08Z")

</div>

e$B1sF#$H?=$7$^$9!#e(B

Binding e$B$KFC0[%a%=%C%I$rDj5A$9$k$He(B eval e$B$G$-$J$/$J$j$^$9$,!"e(B  
e$B0U?^E\*$G$7$g$&$+!#e(B

$ ./ruby -ve ‘x = 1; b = binding; def b.foo; end; p b.eval(“x”)’  
ruby 1.9.0 (2008-02-13 revision 15457) [i686-linux]  
-e:1:in `eval': wrong argument type Binding (expected Binding) (TypeError) from -e:1:in`’

# e$B$=$s$J$3$H$7$M!\<$h$H$$$&%D%C%3%\_$O$41sN82\<$5$$e(B

# Index: eval.c

— eval.c (revision 15454)  
+++ eval.c (working copy)  
@@ -1700,7 +1700,7 @@  
volatile VALUE iseqval;

if (scope != Qnil) {

- 

```
 if (CLASS_OF(scope) == rb_cBinding) {

```

- 

```
 if (rb_obj_is_kind_of(scope, rb_cBinding)) {

```

GetBindingPtr(scope, bind);  
envval = bind-\>env;  
stored\_cref\_stack = bind-\>cref\_stack;

---

<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:** [February 13, 2008, 2:16pm UTC](https://www.ruby-forum.com/t/cannot-eval-in-the-binding-that-has-a-singleton-method/129004/2 "2008-02-13T14:16:50Z")

</div>

e$B!!$5$5$@$G$9!%e(B

Yusuke ENDOH wrote:

> Binding e$B$KFC0[%a%=%C%I$rDj5A$9$k$He(B eval e$B$G$-$J$/$J$j$^$9$,!"e(B  
> e$B0U?^E\*$G$7$g$&$+!#e(B

e$B!!0U?^E\*$8$c$J$$$G$9!%%3%\_%C%H$7$F$\*$$$F$/$@$5$$$^$;!%e(B
