Skip to content

Commit 08d577a

Browse files
committed
Merge pull request #737 from pguyot/w31/fix-more-types
Fix more types and few examples Running dialyzer on atomvmlib and examples revealed issues with several types It also revealed bugs in three examples These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 6d588de + 889abad commit 08d577a

23 files changed

+319
-258
lines changed

examples/erlang/esp32/ap_sta_network.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ start() ->
3636
{sta_connected, fun sta_connected/1},
3737
{sta_ip_assigned, fun sta_ip_assigned/1},
3838
{sta_disconnected, fun sta_disconnected/1},
39-
{ap_sta_ip_assigned, fun ap_sta_ip_assigned/1}
39+
{sta_ip_assigned, fun ap_sta_ip_assigned/1}
4040
]},
4141
{sta, [
4242
{ssid, <<"myssid">>},

examples/erlang/hello_world_server.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ start() ->
3333
{disconnected, fun() -> Self ! disconnected end}
3434
]}
3535
],
36-
case network_fsm:start(Config) of
37-
ok ->
36+
case network:start(Config) of
37+
{ok, _Pid} ->
3838
wait_for_message();
3939
Error ->
4040
io:format("An error occurred starting network: ~p~n", [Error])

examples/erlang/system_info_server.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ start() ->
3333
{disconnected, fun() -> Self ! disconnected end}
3434
]}
3535
],
36-
case network_fsm:start(Config) of
37-
ok ->
36+
case network:start(Config) of
37+
{ok, _Pid} ->
3838
wait_for_message();
3939
Error ->
4040
io:format("An error occurred starting network: ~p~n", [Error])

libs/eavmlib/src/atomvm.erl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838

3939
-type platform_name() ::
4040
generic_unix
41+
| emscripten
4142
| esp32
43+
| pico
4244
| stm32.
4345

4446
-type avm_path() :: string() | binary().
@@ -52,7 +54,7 @@
5254
%%-----------------------------------------------------------------------------
5355
-spec platform() -> platform_name().
5456
platform() ->
55-
throw(nif_error).
57+
erlang:nif_error(undefined).
5658

5759
%%-----------------------------------------------------------------------------
5860
%% @returns random 32-bit integer.
@@ -63,7 +65,7 @@ platform() ->
6365
%%-----------------------------------------------------------------------------
6466
-spec random() -> integer().
6567
random() ->
66-
throw(nif_error).
68+
erlang:nif_error(undefined).
6769

6870
%%-----------------------------------------------------------------------------
6971
%% @param Len non-negative integer
@@ -76,7 +78,7 @@ random() ->
7678
%%-----------------------------------------------------------------------------
7779
-spec rand_bytes(Len :: non_neg_integer()) -> binary().
7880
rand_bytes(_Len) ->
79-
throw(nif_error).
81+
erlang:nif_error(undefined).
8082

8183
%%-----------------------------------------------------------------------------
8284
%% @param App application name.
@@ -87,7 +89,7 @@ rand_bytes(_Len) ->
8789
%%-----------------------------------------------------------------------------
8890
-spec read_priv(App :: atom(), Path :: list()) -> binary().
8991
read_priv(_App, _Path) ->
90-
throw(nif_error).
92+
erlang:nif_error(undefined).
9193

9294
%%-----------------------------------------------------------------------------
9395
%% @param AVMData AVM data.
@@ -104,7 +106,7 @@ read_priv(_App, _Path) ->
104106
%%-----------------------------------------------------------------------------
105107
-spec add_avm_pack_binary(AVMData :: binary(), Options :: [{name, Name :: atom()}]) -> ok.
106108
add_avm_pack_binary(_AVMData, _Options) ->
107-
throw(nif_error).
109+
erlang:nif_error(undefined).
108110

109111
%%-----------------------------------------------------------------------------
110112
%% @param AVMPath Path to AVM data.
@@ -131,7 +133,7 @@ add_avm_pack_binary(_AVMData, _Options) ->
131133
%%-----------------------------------------------------------------------------
132134
-spec add_avm_pack_file(AVMPath :: avm_path(), Options :: []) -> ok.
133135
add_avm_pack_file(_AVMPath, _Options) ->
134-
throw(nif_error).
136+
erlang:nif_error(undefined).
135137

136138
%%-----------------------------------------------------------------------------
137139
%% @param name the AVM name.
@@ -148,4 +150,4 @@ add_avm_pack_file(_AVMPath, _Options) ->
148150
%%-----------------------------------------------------------------------------
149151
-spec close_avm_pack(Name :: atom(), Options :: []) -> ok | error.
150152
close_avm_pack(_Name, _Options) ->
151-
throw(nif_error).
153+
erlang:nif_error(undefined).

libs/eavmlib/src/console.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ flush(Console) ->
7272
%%-----------------------------------------------------------------------------
7373
-spec print(string()) -> ok | {error, term()}.
7474
print(_String) ->
75-
throw(nif_error).
75+
erlang:nif_error(undefined).
7676

7777
%% Internal operations
7878

0 commit comments

Comments
 (0)