Actions
Bug #9353
closedStruct setter methods now return the struct object rather than the value
Description
~ ruby-2.1.0 λ irb
Struct.new(:foo).new.send(:foo=, 123)
=> #
~ ruby-2.0.0-p247 λ irb
Struct.new(:foo).new.send(:foo=, 123)
=> 123
This looks like a regression introduced by r41534, where rb_struct_set was changed:
-
return ptr[i] = val;
-
return RSTRUCT_SET(obj, i, val);
The RSTRUCT_SET macro was introduced in this commit, but it returns obj, not val.
I have attached a patch fixing this issue.
Files
Updated by Anonymous over 10 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r44501.
Charlie, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
-
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
Updated by Anonymous over 10 years ago
- Status changed from Closed to Open
- Assignee set to naruse (Yui NARUSE)
- % Done changed from 100 to 0
- Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: REQUIRED
Updated by naruse (Yui NARUSE) about 10 years ago
- Backport changed from 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: REQUIRED to 1.9.3: DONTNEED, 2.0.0: DONTNEED, 2.1: DONE
Updated by naruse (Yui NARUSE) over 9 years ago
- Status changed from Open to Closed
Actions
Like0
Like0Like0Like0Like0