Skip to content

Add EEP draft for map keys bound in the same pattern - #88

Open
lazedo wants to merge 2 commits into
erlang:masterfrom
lazedo:map-keys-bound-in-pattern
Open

lazedo wants to merge 2 commits into
erlang:masterfrom
lazedo:map-keys-bound-in-pattern

Conversation

@lazedo

@lazedo lazedo commented Nov 11, 2026 •

Copy link
Copy Markdown

This EEP proposes that a map key in a pattern can use variables bound by other parts of the same pattern, in any order, as long as the keys do not depend on each other in a cycle:

local_number(Number, #{numbers := #{Number := Metadata}}) ->
    {Number, Metadata};
local_number(_, _) ->
    not_local.

EEP 43 described this when maps were introduced, but it was never implemented. The EEP also covers the problems that shelved the 2020 prototype: repeated variables such as foo(#{K := K}, K) work, and programs that stay invalid get the same error messages as today.

🤖 Generated with Claude Code

Allow a map key in a pattern to use variables bound by other parts of
the same pattern, as in f(K, #{K := V}), in any order, as long as the
keys do not depend on each other in a cycle.
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