Project

General

Profile

Actions

Bug #18405

closed

Regression in Struct member setter method parameters

Added by ufuk (Ufuk Kayserilioglu) over 2 years ago. Updated over 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.0dev (2021-12-08T10:11:02Z master 3021c3cedc) [x86_64-darwin21]
[ruby-core:106623]

Description

Since the PR optimizing Struct accessors was merged, the behaviour of Method#parameters on Struct member setter methods has changed.

Before:

S = Struct.new(:foo)
S.instance_method(:foo=).parameters
#=> [[:req, :_]]

After:

S = Struct.new(:foo)
S.instance_method(:foo=).parameters
#=> [[:rest]]

This is probably a side-effect of the new optimized accessor implementation that was missed in review.

If this change in behaviour was intentional, though, I think it should be fixed, since it is a little strange for a setter method to claim that it takes zero or more parameters.

Actions #1

Updated by alanwu (Alan Wu) over 2 years ago

  • Backport changed from 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN to 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONTNEED
Actions #3

Updated by ko1 (Koichi Sasada) over 2 years ago

  • Status changed from Open to Closed

Applied in changeset git|6659253cc6c807641e23d469b425ddcf18de7af4.


Struct setter's parameters == [:req, :_]

fix [Bug #18405]

Note that the parameter name _ is not a spec, so we shouldn't
rely on this behavior.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0