Skip to content

Commit

Permalink
Issue erlang#8099: Accept empty list of binaries in binary:join/2 whi…
Browse files Browse the repository at this point in the history
…ch returns an empty binary
  • Loading branch information
onno-vos-dev committed Feb 8, 2024
1 parent 7319cdf commit 53dddc5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/stdlib/src/binary.erl
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ _Example:_
""".
-doc(#{since => <<"OTP 27.0">>}).
-spec join([binary()], binary()) -> binary().
join([], _Separator) -> <<>>;
join([H], _Separator) -> H;
join([H | T], Separator) ->
join(T, Separator, H).
Expand Down
1 change: 1 addition & 0 deletions lib/stdlib/test/binary_module_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,7 @@ do_hex_roundtrip(Bytes) ->
join(Config) when is_list(Config) ->
<<"a, b, c">> = binary:join([<<"a">>, <<"b">>, <<"c">>], <<", ">>),
<<"a">> = binary:join([<<"a">>], <<", ">>),
<<>> = binary:join([], <<", ">>),
badarg = ?MASK_ERROR(binary:join([<<"a">>], ", ")),
badarg = ?MASK_ERROR(binary:join([], <<",">>)).

Expand Down

0 comments on commit 53dddc5

Please sign in to comment.