diff options
| author | Benoit Daloze <eregontp@gmail.com> | 2025-11-05 11:13:09 +0100 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2025-12-02 17:27:38 +0000 |
| commit | d3907245d7928279fcffd1af2903d16b2dbb2d29 (patch) | |
| tree | 3664a14e3480cd167ff197cd8323ef505f6252f8 /include | |
| parent | 17bcd71e4218994bfb6c2d398fa784ccd74d2f2c (diff) | |
[ruby/psych] Fix usage of rb_struct_initialize() to pass an Array of members values and not a Hash
* rb_struct_initialize() does not accept a Hash, and it's very brittle
to pass `[{...}]` and to rely on that C function using rb_keyword_given_p().
It basically worked accidentally, by having **members in the caller of the caller.
Such logic when Struct#initialize is defined in Ruby (as in TruffleRuby) is basically impossible to implement,
because it's incorrectly treating positional arguments as keyword arguments.
* rb_struct_initialize() is used in CRuby to set members of Data instances in marshal.c (there is no rb_data_initialize() yet).
There, the code passes an Array of members values for Data (and for Struct which are not `keyword_init: true`):
https://github.com/ruby/ruby/blob/48c7f349f68846e10d60ae77ad299a38ee014479/marshal.c#L2150-L2176
So we should do the same in psych.
* Rename to init_data since it's only used for Data.
* See https://github.com/ruby/psych/pull/692#discussion_r2483947279.
https://github.com/ruby/psych/commit/3550148378
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions
