Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splatted kwarg struct init #5453

Merged
merged 2 commits into from Nov 19, 2018

Conversation

Projects
None yet
1 participant
@headius
Copy link
Member

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 headius:splatted_kwarg_struct_init branch 2 times, most recently from eef9372 to 786c93c Nov 19, 2018

headius added some commits Nov 19, 2018

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 #5448.

@headius headius force-pushed the headius:splatted_kwarg_struct_init branch from 786c93c to 3985b81 Nov 19, 2018

@headius headius merged commit 5c4838f into jruby:master Nov 19, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@headius headius deleted the headius:splatted_kwarg_struct_init branch Nov 19, 2018

eregon added a commit to ruby/spec that referenced this pull request Nov 27, 2018

Splatted kwarg struct init (jruby/jruby#5453)
* 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
You can’t perform that action at this time.