Skip to main content

L1328 - Illegal Map Exact Association in Comprehension

Error

foo(L) ->
#{K := V || K := V <- L}.
%% ^^ error: illegal map association, did you mean to use `=>`?

Explanation

Map comprehensions produce new maps, so the template must use the => (assoc) syntax, not := (exact). The := syntax is for map updates and pattern matching, not for creating new map entries.

%% Instead of:
foo(L) -> #{K := V || K := V <- L}.

%% Write:
foo(L) -> #{K => V || K := V <- L}.

Note that := is still valid in the generator part (the <- side) — only the template (left of ||) must use =>.