You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original reporter: rodrigues
Affected versions: OTP-22.0, OTP-21.3
Fixed in version: OTP-23.0
Component: dialyzer
Migrated from: https://bugs.erlang.org/browse/ERL-1002
I believe the following behaviour is a bug, as I specify that a function should return a map with a certain atom key (required), but it could never return it, and dialyzer still passes.
{code:erlang}
-module(test).
-export([foo/0]).
-type t() :: #{a := non_neg_integer()}.
-spec foo() -> t().
%% this passes in dialyzer, but I think it's a bug,
%% as it will always return a map without the key a
foo() -> maps:remove(a, #{a => 2}).
%% this passes in dialyzer, as expected
%% foo() -> #{a => 2}.
%% only for these the required key is checked
%% foo() -> #{}.
%% foo() -> #{another => thing}.
{code}
{code:shell}
$ dialyzer test.erl
Checking whether the PLT /Users/rodrigues/.dialyzer_plt is up-to-date... yes
Proceeding with analysis... done in 0m0.12s
done (passed successfully)
{code}
FYI, if it helps, the context where this was discovered: https://elixirforum.com/t/elixir-allows-map-functions-to-manipulate-structs/23826/14?u=rodrigues
The text was updated successfully, but these errors were encountered:
Hi Hans, yes, it works fine for me, thanks! 👍
In that example, now I get:
{{test.erl:6: Invalid type specification for function test:foo/0. The success typing is}}
{{() -> #{}}}
Original reporter:
rodrigues
Affected versions:
OTP-22.0
,OTP-21.3
Fixed in version:
OTP-23.0
Component:
dialyzer
Migrated from: https://bugs.erlang.org/browse/ERL-1002
The text was updated successfully, but these errors were encountered: