Skip to content

Commit

Permalink
Merge pull request #4901 from bjorng/bjorn/fix-error-info/GH-4900/OTP…
Browse files Browse the repository at this point in the history
…-17449

Correct error message for binary_to_existing_atom/2
  • Loading branch information
bjorng authored May 28, 2021
2 parents e39afff + c1942e3 commit cacfc87
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions erts/emulator/test/exception_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,9 @@ error_info(_Config) ->
{binary_to_existing_atom, [abc, latin1]},
{binary_to_existing_atom, [<<128,128,255>>,utf8]},
{binary_to_existing_atom, [list_to_binary(NewAtom), latin1]},
{binary_to_existing_atom, [list_to_binary(NewAtom), utf8]},
{binary_to_existing_atom, [list_to_binary(NewAtom), utf42]},
{binary_to_existing_atom, [[<<"abc">>], utf8]},
{binary_to_existing_atom, [<<0:512/unit:8>>, latin1]},

{binary_to_float, [abc]},
Expand Down
10 changes: 8 additions & 2 deletions lib/kernel/src/erl_erts_errors.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,12 @@ do_binary_to_atom(Bin, Enc0, DefaultError) ->
unicode ->
if
is_binary(Bin) ->
[bad_unicode];
case unicode:characters_to_list(Bin, Enc) of
CharList when is_list(CharList) ->
[non_existing_atom];
_ ->
[bad_unicode]
end;
true ->
[not_binary]
end;
Expand All @@ -1239,7 +1244,8 @@ is_flat_char_list([H|T]) ->
error:badarg ->
false
end;
is_flat_char_list(_) -> true.
is_flat_char_list([]) -> true;
is_flat_char_list(_) -> false.

format_error_map([""|Es], ArgNum, Map) ->
format_error_map(Es, ArgNum + 1, Map);
Expand Down

0 comments on commit cacfc87

Please sign in to comment.