1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

vm_eval.c: fstring instance_eval

* vm_eval.c (singleton_class_for_eval): enable fstring singleton
  class for instance_eval.  [ruby-core:78116] [Bug #12930]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-11-14 05:17:55 +00:00
parent c0af2a1641
commit 8bc277f1d2
2 changed files with 10 additions and 0 deletions

View file

@ -503,6 +503,14 @@ class TestEval < Test::Unit::TestCase
assert_same a, b assert_same a, b
end end
def test_fstring_instance_eval
bug = "[ruby-core:78116] [Bug #12930]".freeze
assert_same bug, (bug.instance_eval {self})
assert_raise(RuntimeError) {
bug.instance_eval {@ivar = true}
}
end
def test_gced_binding_block def test_gced_binding_block
assert_normal_exit %q{ assert_normal_exit %q{
def m def m

View file

@ -1669,6 +1669,8 @@ singleton_class_for_eval(VALUE self)
switch (BUILTIN_TYPE(self)) { switch (BUILTIN_TYPE(self)) {
case T_FLOAT: case T_BIGNUM: case T_SYMBOL: case T_FLOAT: case T_BIGNUM: case T_SYMBOL:
return Qnil; return Qnil;
case T_STRING:
if (FL_TEST_RAW(self, RSTRING_FSTR)) return Qnil;
default: default:
return rb_singleton_class(self); return rb_singleton_class(self);
} }