Skip to content

Splatted kwarg struct init#5453

Merged
headius merged 2 commits intojruby:masterfrom
headius:splatted_kwarg_struct_init
Nov 19, 2018
Merged

Splatted kwarg struct init#5453
headius merged 2 commits intojruby:masterfrom
headius:splatted_kwarg_struct_init

Conversation

@headius
Copy link
Member

@headius headius commented Nov 19, 2018

This includes a fix and spec for initializing a non-kwarg Struct with a splatted Hash-containing array of arguments, as in this snippit that reproduces #5448:

Struct.new(:args).new(*[{keyword: :arg}])

The Hash should not be interpreted to be keyword init of the Struct, since it is not a kwarg-initializable Struct. We simply weren't checking this flag on one path, and assuming a single Hash arg was always for kwarg init.

@headius headius added this to the JRuby 9.2.5.0 milestone Nov 19, 2018
@headius headius force-pushed the splatted_kwarg_struct_init branch 2 times, most recently from eef9372 to 786c93c Compare November 19, 2018 16:21
This case should continue to pass the Hash as a normal field init
arg, and not interpret it as keyword-based init.

See jruby#5448.
@headius headius force-pushed the splatted_kwarg_struct_init branch from 786c93c to 3985b81 Compare November 19, 2018 17:11
@headius headius merged commit 5c4838f into jruby:master Nov 19, 2018
@headius headius deleted the splatted_kwarg_struct_init branch November 19, 2018 17:32
eregon pushed a commit to ruby/spec that referenced this pull request Nov 27, 2018
* Handle splatted and unsplatted kwarg Struct init the same.

Fixes jruby/jruby#5448.

* Init of non-kwarg Struct with splatted args containing Hash.

This case should continue to pass the Hash as a normal field init
arg, and not interpret it as keyword-based init.

See jruby/jruby#5448.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant