dialyzer

Why Erlang Dialyzer cannot find type error in the following code?

天大地大妈咪最大 提交于 2019-12-24 05:49:43
问题 free_vars_in_dterm({var, V}) -> {var, V}; obviously cannot type check, however, dialyzer says everything is OK. $ dialyzer *erl Checking whether the PLT ~/.dialyzer_plt is up-to-date... yes Proceeding with analysis... done in 0m0.66s done (passed successfully) Code is as below: -module(formulas). -type formulas() :: {predicate(), [dterm()]} | {'~', formulas()} | {'&', formulas(), formulas()} | {'|', formulas(), formulas()} | {'->', formulas(), formulas()} | {'<->', formulas(), formulas()} | {

dialyzer not detecting guard violation when function is exported

让人想犯罪 __ 提交于 2019-12-23 10:57:05
问题 Dialyzer version 2.9. Erts 7.3. OTP 18. In the following contrived erlang code: -module(dialBug). -export([test/0]). %-export([f1/1]). % uncomment this line test() -> f1(1). f1(X) when X > 5 -> X*2. When dialyzer is run over the above code it warns that the code won't work as the guard test (X > 5) can never succeed. However, when I uncomment the 3rd line and export the f1/1 function dialyzer no longer issues any warnings. I realise that when f1/1 is exported it is impossible for dialyzer to

dialyxir mix task to create PLT exits without error or creating table

喜夏-厌秋 提交于 2019-12-20 06:39:55
问题 I am trying to use dialyxir to run dialyzer analysis on my project through the mix tasks it provides. I have added it to my dependencies and compiled as per the README. When I run the mix dialyxir.plt it reports no error and yet exits without creating the table. $ mix dialyzer.plt Starting PLT Core Build ... this will take awhile dialyzer --build_plt --output_plt /home/vagrant/.dialyxir_core_19_1.3.2.plt --apps erts kernel stdlib crypto public_key -r /usr/local/lib/elixir/bin/../lib/elixir/..

Erlang Dialyzer integer ranges

天大地大妈咪最大 提交于 2019-12-13 16:05:01
问题 -module(test). -export([f/0, g/0]). -spec f() -> RESULT when RESULT :: 0..12 . -spec g() -> RESULT when RESULT :: 0..13 . f () -> 100 . g () -> 100 . Running dialyzer (and typer) only the function f is caught. dialyzer test.erl Checking whether the PLT /Users/ben/.dialyzer_plt is up-to-date... yes Proceeding with analysis... test.erl:4: Invalid type specification for function test:f/0. The success typing is () -> 100 done in 0m0.53s done (warnings were emitted) the same with typer typer test

Type of non-terminating function in erlang

时光毁灭记忆、已成空白 提交于 2019-12-12 12:13:53
问题 I'm learning erlang and trying to use dialyzer to get maximum type-safety when it's possible. There's a thing that I don't understand: what is the type of non-terminating function and how to denote it in spec. Could you please shed a light on this? 回答1: A function that loops forever and never terminates has the return type no_return() . (That return type is also used for functions that always throw exceptions, e.g. a custom error function. If you don't specify that return type, Dialyzer will

How to use dialyzer with parse transform modules

最后都变了- 提交于 2019-12-12 00:44:48
问题 I'm trying to use dialyzer on my erlang application but here's the output : dialyzer \ --src -r src \ -pa /home/niahoo/src/popos \ -pa /home/niahoo/src/popos/deps/parse_trans \ --verbose Checking whether the PLT c:/MinGW/msys/1.0/home/niahoo/.dialyzer_plt is up-to-date... yes Proceeding with analysis... dialyzer: Analysis failed with error: Could not scan the following file(s): [{"c:/MinGW/msys/1.0/home/niahoo/src/popos/src/tools/r.erl", ["c:/MinGW/msys/1.0/home/niahoo/src/popos/src/tools/r

Elixir / Erlang Dialyzer : Why behaviour callback's param type should be subtype instead of supertype?

£可爱£侵袭症+ 提交于 2019-12-11 08:48:48
问题 I have a behaviour X and a callback function with parameter type: %{a: any} Module Y implements behaviour X and the callback function in implementing module Y has parameter type: %{a: any, b: any} Dialyzer doesn't like that and complains: (#{'a':=_, 'b':=_, _=>_}) is not a supertype of #{'a':=_} This implies dialyzer attempts to determine if callback parameter's type in implementing module Y is a supertype of param type in behaviour X. In other words, it asks: Is behaviour X's callback param

Dialyzer error for struct

走远了吗. 提交于 2019-12-11 06:36:32
问题 Here's a minimum broken example in Elixir 1.3: defmodule Foo do @type t :: %__MODULE__{x: non_neg_integer} defstruct x: 0 @spec test(t) :: t def test(%__MODULE__{} = foo), do: test2(foo) @spec test2(t) :: t defp test2(%__MODULE__{} = foo), do: %__MODULE__{foo | x: 5} end This fails to type check with: foo.ex:9: The variable _@1 can never match since previous clauses completely covered the type #{'__struct__':='Elixir.Foo', _=>_} . I've searched and searched and cannot for the life of me find

“Dialyzer is usually never wrong”, but I can't figure out how my @spec is incorrect

…衆ロ難τιáo~ 提交于 2019-12-11 05:34:45
问题 I have some code that is failing dialyzer and I cannot understand why. No matter what I put into the @spec at the top of the function, calls to that function return a puzzling dialyzer error. Here is a simplification of the function. As far as I can tell, I have spec'd the function correctly. @spec balances(uuid :: String.t(), retries :: non_neg_integer) :: {:ok, list()} | {:internal_server_error, String.t(), String.t()} | {:internal_server_error, map | list, String.t()} def balances(uuid,

dialyxir mix task to create PLT exits without error or creating table

僤鯓⒐⒋嵵緔 提交于 2019-12-02 10:08:23
I am trying to use dialyxir to run dialyzer analysis on my project through the mix tasks it provides. I have added it to my dependencies and compiled as per the README. When I run the mix dialyxir.plt it reports no error and yet exits without creating the table. $ mix dialyzer.plt Starting PLT Core Build ... this will take awhile dialyzer --build_plt --output_plt /home/vagrant/.dialyxir_core_19_1.3.2.plt --apps erts kernel stdlib crypto public_key -r /usr/local/lib/elixir/bin/../lib/elixir/../eex/ebin /usr/local/lib/elixir/bin/../lib/elixir/../elixir/ebin /usr/local/lib/elixir/bin/../lib