-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Raise ArgumentError in Keyword.keys when list is not a keyword list #10214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raise ArgumentError in Keyword.keys when list is not a keyword list #10214
Conversation
d864c96
to
276ee6e
Compare
Previously it would return something like this: ** (FunctionClauseError) no function clause matching in anonymous fn/1 in Keyword.keys/1 The following arguments were given to anonymous fn/1 in Keyword.keys/1: # 1 {"fetch/2", {:fetch, 2}} Closes elixir-lang#10010, and it improves 3fd68ef
lib/elixir/lib/keyword.ex
Outdated
"expected a keyword list, but an element in the list is not a keyword; got: #{ | ||
inspect(element) | ||
}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"expected a keyword list, but an element in the list is not a keyword; got: #{ | |
inspect(element) | |
}" | |
"expected a keyword list, but an element in the list is not a two-element tuple with atom key, " <> | |
"got: #{inspect(element)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement your suggestion with the addition of the article "an".
I am not 100% sure on the accuracy of the message though, as tuples don't have keys.
How about something like this?
expected a keyword list, but an element in the list is not a two-element tuple with its first element being an atom; got:
Raising deep from within the map call might result in a pretty poor error message with the whole printable stacktrace being only the |
f5aeb9e
to
272e1a2
Compare
💚 💙 💜 💛 ❤️ |
Previously it would return something like this:
** (FunctionClauseError) no function clause matching in anonymous fn/1 in Keyword.keys/1
Closes #10010, and it improves 3fd68ef