summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-05 04:05:53 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-05 04:05:53 +0000
commit9b614cb0e947904b8d1543440f34f9c5ca315e00 (patch)
treeabedac3349bbccb85021efb535b9e758833999ad
parent3e5f9b16d034e3501b47ce19297e8458345080e8 (diff)
downloadruby-9b614cb0e947904b8d1543440f34f9c5ca315e00.tar.gz
merge revision(s) 44501: [Backport #9353]
* struct.c (rb_struct_set): return assigned value from setter method rather than struct object. [Bug #9353] [ruby-core:59509] * test/ruby/test_struct.rb (test_setter_method_returns_value): add test git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/branches/ruby_2_1@44826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--struct.c3
-rw-r--r--test/ruby/test_struct.rb6
-rw-r--r--version.h2
4 files changed, 16 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 465620e557..d8aae5a043 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Feb 5 11:48:42 2014 Charlie Somerville <charliesome@ruby-lang.org>
+
+ * struct.c (rb_struct_set): return assigned value from setter method
+ rather than struct object. [Bug #9353] [ruby-core:59509]
+
+ * test/ruby/test_struct.rb (test_setter_method_returns_value): add test
+
Wed Feb 5 11:13:21 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_modify_expand): enable capacity and disable
diff --git a/struct.c b/struct.c
index 6be512eaee..2e026fbc7f 100644
--- a/struct.c
+++ b/struct.c
@@ -156,7 +156,8 @@ rb_struct_set(VALUE obj, VALUE val)
for (i=0; i<len; i++) {
slot = RARRAY_AREF(members, i);
if (rb_id_attrset(SYM2ID(slot)) == rb_frame_this_func()) {
- return RSTRUCT_SET(obj, i, val);
+ RSTRUCT_SET(obj, i, val);
+ return val;
}
}
rb_name_error(rb_frame_this_func(), "`%s' is not a struct member",
diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb
index 8aa99c52fb..e23b5b021c 100644
--- a/test/ruby/test_struct.rb
+++ b/test/ruby/test_struct.rb
@@ -298,6 +298,12 @@ module TestStruct
assert_same(x, o.b!)
end
+ def test_setter_method_returns_value
+ klass = @Struct.new(:a)
+ x = klass.new
+ assert_equal "[Bug #9353]", x.send(:a=, "[Bug #9353]")
+ end
+
class TopStruct < Test::Unit::TestCase
include TestStruct
diff --git a/version.h b/version.h
index 98bc2a3642..a3977f41fc 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.1"
#define RUBY_RELEASE_DATE "2014-02-05"
-#define RUBY_PATCHLEVEL 16
+#define RUBY_PATCHLEVEL 17
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 2