Skip to content

Improve defstruct @enforce_keys - #15826

Merged
josevalim merged 3 commits into
elixir-lang:mainfrom
AlexGx:ag-defstruct_enforce_keys-fix
Sep 2, 2026
Merged

Improve defstruct @enforce_keys#15826
josevalim merged 3 commits into
elixir-lang:mainfrom
AlexGx:ag-defstruct_enforce_keys-fix

Conversation

@AlexGx

@AlexGx AlexGx commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Validates @enforce_keys against declared struct fields

@AlexGx AlexGx changed the title Improve defstruct @enfore_keys Improve defstruct @enforce_keys Sep 1, 2026
@josevalim

Copy link
Copy Markdown
Member

Thank you but I think we can simplify the message instead:

unknown or duplicate keys given to @enforce_keys, got: [....]

And we just make sure the struct key is not taken into account and is part of the same error message. That should be much simpler.

@AlexGx
AlexGx force-pushed the ag-defstruct_enforce_keys-fix branch from 6c348ae to b692382 Compare September 1, 2026 13:18
Comment thread lib/elixir/test/elixir/map_test.exs Outdated
@josevalim
josevalim merged commit d4b2c58 into elixir-lang:main Sep 2, 2026
15 checks passed
@josevalim

Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

@AlexGx
AlexGx deleted the ag-defstruct_enforce_keys-fix branch September 2, 2026 20:21
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