Skip to content

Commit 9b614cb

Browse files
committed
merge revision(s) 44501: [Backport ruby#9353]
* struct.c (rb_struct_set): return assigned value from setter method rather than struct object. [Bug ruby#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
1 parent 3e5f9b1 commit 9b614cb

4 files changed

Lines changed: 16 additions & 2 deletions

File tree

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Wed Feb 5 11:48:42 2014 Charlie Somerville <charliesome@ruby-lang.org>
2+
3+
* struct.c (rb_struct_set): return assigned value from setter method
4+
rather than struct object. [Bug #9353] [ruby-core:59509]
5+
6+
* test/ruby/test_struct.rb (test_setter_method_returns_value): add test
7+
18
Wed Feb 5 11:13:21 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
29

310
* string.c (rb_str_modify_expand): enable capacity and disable

struct.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ rb_struct_set(VALUE obj, VALUE val)
156156
for (i=0; i<len; i++) {
157157
slot = RARRAY_AREF(members, i);
158158
if (rb_id_attrset(SYM2ID(slot)) == rb_frame_this_func()) {
159-
return RSTRUCT_SET(obj, i, val);
159+
RSTRUCT_SET(obj, i, val);
160+
return val;
160161
}
161162
}
162163
rb_name_error(rb_frame_this_func(), "`%s' is not a struct member",

test/ruby/test_struct.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ def test_bang_mark_in_member
298298
assert_same(x, o.b!)
299299
end
300300

301+
def test_setter_method_returns_value
302+
klass = @Struct.new(:a)
303+
x = klass.new
304+
assert_equal "[Bug #9353]", x.send(:a=, "[Bug #9353]")
305+
end
306+
301307
class TopStruct < Test::Unit::TestCase
302308
include TestStruct
303309

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.1"
22
#define RUBY_RELEASE_DATE "2014-02-05"
3-
#define RUBY_PATCHLEVEL 16
3+
#define RUBY_PATCHLEVEL 17
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 2

0 commit comments

Comments
 (0)