summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_eval.rb8
-rw-r--r--vm_eval.c2
2 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb
index dba5477..fc08d61 100644
--- a/test/ruby/test_eval.rb
+++ b/test/ruby/test_eval.rb
@@ -503,6 +503,14 @@ class TestEval < Test::Unit::TestCase
assert_same a, b
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
assert_normal_exit %q{
def m
diff --git a/vm_eval.c b/vm_eval.c
index ea398e0..f0274e1 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1669,6 +1669,8 @@ singleton_class_for_eval(VALUE self)
switch (BUILTIN_TYPE(self)) {
case T_FLOAT: case T_BIGNUM: case T_SYMBOL:
return Qnil;
+ case T_STRING:
+ if (FL_TEST_RAW(self, RSTRING_FSTR)) return Qnil;
default:
return rb_singleton_class(self);
}