Skip to content

Commit

Permalink
kernel: fixes socket.erl type spec
Browse files Browse the repository at this point in the history
the type specs for socker.erl were improved in PR-8986, but they
introduced a bug by omitting one of the overloaded specs. this commit
fixes that, and adds a test to check for it
  • Loading branch information
kikofernandez committed Jan 14, 2025
1 parent 5674bfc commit b8599b0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Empty file.
17 changes: 17 additions & 0 deletions lib/dialyzer/test/small_SUITE_data/src/sock.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-module(sock).

-export([sendto/4]).

family({_,_,_,_}) -> inet;
family({_,_,_,_,_,_,_,_}) -> inet6.

sendto(Socket, IP, Port, Data) ->
Dest = #{family => family(IP),
addr => IP,
port => Port},
case socket:sendto(Socket, Data, Dest, nowait) of
ok -> ok;
Other ->
logger:debug("sendto(~p) failed with: ~p", [Dest, Other]),
ok
end.
4 changes: 3 additions & 1 deletion lib/kernel/src/socket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3763,7 +3763,9 @@ an explanation of `TimeoutOrHandle`.
""".

-spec sendto(Socket :: socket(), Data :: iodata(),
Dest :: sockaddr(), Flags :: list()) -> Result when
Dest :: sockaddr(), Flags | TimeoutOrHandle) -> Result when
TimeoutOrHandle :: dynamic(),
Flags :: list(),
Result :: 'ok'
| {'ok', RestData :: binary()}
| {'error', Reason}
Expand Down

0 comments on commit b8599b0

Please sign in to comment.