ruby-changes:46087
From: nagachika <ko1@a...>
Date: Tue, 28 Mar 2017 00:09:00 +0900 (JST)
Subject: [ruby-changes:46087] nagachika:r58157 (ruby_2_3): merge revision(s) 56747, 56754, 56777: [Backport #12923] [Backport #12930] [Backport #13238]
nagachika 2017-03-28 00:08:54 +0900 (Tue, 28 Mar 2017) New Revision: 58157 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58157 Log: merge revision(s) 56747,56754,56777: [Backport #12923] [Backport #12930] [Backport #13238] class.c: no fstring singleton class * class.c (singleton_class_of): prohibit fstrings from creating singleton classes. temporary measure for [ruby-dev:49867] [Bug #12923] test_fstring.rb: fix exception * test/-ext-/string/test_fstring.rb (test_singleton_class): fix expected exception class. [ruby-dev:49867] [Bug #12923] 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] Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/class.c branches/ruby_2_3/test/-ext-/string/test_fstring.rb branches/ruby_2_3/test/ruby/test_eval.rb branches/ruby_2_3/version.h branches/ruby_2_3/vm_eval.c Index: ruby_2_3/vm_eval.c =================================================================== --- ruby_2_3/vm_eval.c (revision 58156) +++ ruby_2_3/vm_eval.c (revision 58157) @@ -1667,6 +1667,8 @@ singleton_class_for_eval(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/vm_eval.c#L1667 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); } Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 58156) +++ ruby_2_3/version.h (revision 58157) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.3" #define RUBY_RELEASE_DATE "2017-03-27" -#define RUBY_PATCHLEVEL 267 +#define RUBY_PATCHLEVEL 268 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_3/class.c =================================================================== --- ruby_2_3/class.c (revision 58156) +++ ruby_2_3/class.c (revision 58157) @@ -1578,6 +1578,9 @@ singleton_class_of(VALUE obj) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/class.c#L1578 switch (BUILTIN_TYPE(obj)) { case T_FLOAT: case T_BIGNUM: case T_SYMBOL: goto no_singleton; + case T_STRING: + if (FL_TEST_RAW(obj, RSTRING_FSTR)) goto no_singleton; + break; } } Index: ruby_2_3/test/ruby/test_eval.rb =================================================================== --- ruby_2_3/test/ruby/test_eval.rb (revision 58156) +++ ruby_2_3/test/ruby/test_eval.rb (revision 58157) @@ -504,6 +504,14 @@ class TestEval < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_eval.rb#L504 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 Index: ruby_2_3/test/-ext-/string/test_fstring.rb =================================================================== --- ruby_2_3/test/-ext-/string/test_fstring.rb (revision 58156) +++ ruby_2_3/test/-ext-/string/test_fstring.rb (revision 58157) @@ -1,8 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/-ext-/string/test_fstring.rb#L1 # frozen_string_literal: false require 'test/unit' require '-test-/string' +require_relative '../symbol/noninterned_name' class Test_String_Fstring < Test::Unit::TestCase + include Test_Symbol::NonInterned + def assert_fstring(str) fstr = Bug::String.fstring(str) yield str @@ -54,6 +57,12 @@ class Test_String_Fstring < Test::Unit:: https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/-ext-/string/test_fstring.rb#L57 assert_fstring(str) {|s| assert_send([s, :respond_to?, :foo])} end + def test_singleton_class + str = noninterned_name.force_encoding("us-ascii") + fstr = Bug::String.fstring(str) + assert_raise(TypeError) {fstr.singleton_class} + end + class S < String end Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r56747,56754,56777 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/