Map comprehension behavior

Erlang/OTP 27 [erts-15.2.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

Eshell V15.2.1 (press Ctrl+G to abort, type help(). for help)
1> #{ K => V || K <- [1,2,3], V <- [a,b,c]}.
#{1 => a,2 => a,3 => a}
2> maps:from_list([{K,V} || K <- [1,2,3], V <- [a,b,c]]).
#{1 => c,2 => c,3 => c}

I guess the docs are silent about the order in which the second list is processed, but wouldn’t it be reasonable to assume the two expressions above to be equivalent?

Granted, I will not volunteer a more detailed specification. :slight_smile:

BR,
Ulf W

1 Like

Hi! The two results are supposed to be the same, and #{1 => c,2 => c,3 => c} is the correct one. It looks like this bug, which was fixed in 28.
I tested your example locally on 28, and I didn’t see a problem. If you still see some kind of inconsistency for map comprehensions in 28, please report it as a bug to OTP. Thanks!

2 Likes

Thanks!

And apologies for not checking on 28 myself. :slight_smile:

1 Like