Project

General

Profile

Actions

Bug #9353

closed

Struct setter methods now return the struct object rather than the value

Added by Anonymous over 10 years ago. Updated over 9 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
[ruby-core:59509]

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

rb_struct_set-regression.patch (437 Bytes) rb_struct_set-regression.patch Anonymous, 01/03/2014 06:31 PM
Actions #1

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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0