File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -1163,7 +1163,7 @@ defmodule KeyError do
1163
1163
end
1164
1164
1165
1165
defp map_with_atom_keys_only? ( term ) do
1166
- is_map ( term ) and Enum . all? ( term , fn { k , _ } -> is_atom ( k ) end )
1166
+ is_map ( term ) and Enum . all? ( Map . to_list ( term ) , fn { k , _ } -> is_atom ( k ) end )
1167
1167
end
1168
1168
1169
1169
defp available_keys ( term ) when is_map ( term ) , do: Map . keys ( term )
Original file line number Diff line number Diff line change @@ -510,6 +510,13 @@ defmodule ExceptionTest do
510
510
"""
511
511
end
512
512
513
+ test "annotates key error with suggestions for structs" do
514
+ message = blame_message ( % URI { } , fn map -> map . schema end )
515
+ assert message =~ "key :schema not found in: %URI{"
516
+ assert message =~ "Did you mean one of:"
517
+ assert message =~ "* :scheme"
518
+ end
519
+
513
520
if :erlang . system_info ( :otp_release ) >= '21' do
514
521
test "annotates +/1 arithmetic errors" do
515
522
assert blame_message ( :foo , & ( + & 1 ) ) == "bad argument in arithmetic expression: +(:foo)"
You can’t perform that action at this time.
0 commit comments