Skip to content

Conversation

@sabiwara
Copy link
Contributor

@sabiwara sabiwara commented Feb 18, 2023

This should be the last fix regarding non-deterministic key order in OTP26 maps.

  • One fix to make struct expansion deterministic
  • One fix to make pattern typing deterministic

Screenshot 2023-02-18 at 23 07 37

Screenshot 2023-02-18 at 23 08 02


entries =
for key <- Map.keys(struct.__struct__()), key != :__struct__ do
for key <- Map.keys(struct.__struct__()) |> :lists.sort(), key != :__struct__ do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is only going to affect error messages, right? Maybe we should order in the error messages then?

Copy link
Contributor Author

@sabiwara sabiwara Feb 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message seems to already be sorted here: https://github.com/elixir-lang/elixir/blob/main/lib/elixir/lib/module/types.ex#L257.
I will just fix tests to remove the influence of ordering there: 997e18e

@sabiwara sabiwara force-pushed the deterministic-struct-expansion branch from 16bba32 to 997e18e Compare February 19, 2023 00:14
@josevalim josevalim merged commit 0800222 into elixir-lang:main Feb 19, 2023
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

josevalim pushed a commit that referenced this pull request Feb 19, 2023
@sabiwara sabiwara deleted the deterministic-struct-expansion branch February 19, 2023 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants