Skip to content

Commit dbea224

Browse files
committed
Always return binary strings from get_line
Closes gleam-lang/gleam#1252
1 parent 42c7063 commit dbea224

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/gleam_erlang_ffi.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ atom_from_dynamic(Data) when is_atom(Data) ->
2323
atom_from_dynamic(_) ->
2424
{error, list_to_binary("expected an atom, got some other type")}.
2525

26-
-spec get_line(io:prompt()) -> {ok, string() | unicode:unicode_binary()} | {error, eof} | {error, no_data}.
26+
-spec get_line(io:prompt()) -> {ok, unicode:unicode_binary()} | {error, eof | no_data}.
2727
get_line(Prompt) ->
2828
case io:get_line(Prompt) of
2929
eof -> {error, eof};
3030
{error, _} -> {error, no_data};
31-
Data -> {ok, Data}
31+
Data when is_binary(Data) -> {ok, Data};
32+
Data when is_list(Data) -> {ok, unicode:characters_to_binary(Data)}
3233
end.

0 commit comments

Comments
 (0)