Skip to content

Preserve insertion order for ivars#7993

Merged
headius merged 2 commits intojruby:masterfrom
headius:ivar_insertion_order
Oct 31, 2023
Merged

Preserve insertion order for ivars#7993
headius merged 2 commits intojruby:masterfrom
headius:ivar_insertion_order

Conversation

@headius
Copy link
Member

@headius headius commented Oct 31, 2023

I could not find anywhere this is specified, except for:

  • A very recent test in CRuby's test/ruby/test_shape.rb that confirms a degraded "complex" shape using CRuby's "st table" hashtable will continue to be returned in insertion order. This implies that insertion order is expected.
  • A rubyspec added in 2021 in instance_variable_spec.rb that confirms instance variables are returned in insertion order. No links to issues or discussions is provided.

Since this is a simple enough change, we'll go ahead with it, but I don't know that it has ever been formally specified (and indeed I looked through other tests of other types of variables and see that there are commits to .sort them before inspection in tests.)

Fixes #7988

I could not find anywhere this is specified, except for:

* A very recent test in CRuby's test/ruby/test_shape.rb that
  confirms a degraded "complex" shape using CRuby's "st table"
  hashtable will continue to be returned in insertion order. This
  implies that insertion order is expected.
* A rubyspec added in 2021 in instance_variable_spec.rb that
  confirms instance variables are returned in insertion order. No
  links to issues or discussions is provided.

Since this is a simple enough change, we'll go ahead with it, but
I don't know that it has ever been formally specified (and indeed
I looked through other tests of other types of variables and see
that there are commits to .sort them before inspection in tests.)

Fixes jruby#7988
@headius headius added this to the JRuby 9.4.5.0 milestone Oct 31, 2023
@headius headius merged commit 9210a73 into jruby:master Oct 31, 2023
@headius headius deleted the ivar_insertion_order branch October 31, 2023 19:05
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.

JRuby 9.4 appears to re-order array parallel assigns

2 participants