Closed
Description
Environment
- Elixir version (elixir -v):
Erlang/OTP 19 [erts-8.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
Elixir 1.3.4
- Operating system:
tobi@happy ~ $ uname -a
Linux happy 3.19.0-32-generic #37~14.04.1-Ubuntu SMP Thu Oct 22 09:41:40 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Current behavior
The current behaviour is that when Keyword.merge is called with a normal list as the second argument it just appends the list.
iex(1)> Keyword.merge [a: 1], [b: 2]
[a: 1, b: 2]
iex(2)> Keyword.merge [a: 1], [2, 3]
[{:a, 1}, 2, 3]
Expected behavior
Not sure, part of what this is about :) I see 3 options:
- throw an error (as the second argument is no keyword list).
- The current behavior can be argued for and could be declared wanted behaviour, in that case I'd want to add a unit test for it and some documentation (there doesn't seem to be any for this case atm)
- it could be declared "undefined behaviour" and marked as such
I'd have expected 1.) to happen but through the internal representation can also understand that 2.) might be a good course of action.
Thanks for all your effort + Cheers,
Tobi