Age | Commit message (Collapse) | Author |
|
Warnings are not generated for funs residing in dead code.
In particular, warnings like "The created fun has no local return" are
no longer generated for funs declared in clauses or functions that
cannot be run.
|
|
* maint:
dialyzer: Correct a parameterized opaque types bug
|
|
See also https://bugs.erlang.org/browse/ERL-565.
To avoid loops, erl_types:t_is_subtype checks for equality using
unopaqued types, but in (at least) one case something is lost:
This fix makes sure that when forwarding arguments in dataflow, types
with different parameters but equal when unopaqued are considered
different.
For example, dict:dict(0, {}) and dict:dict(0, []) are equal when
unopaqued (due to how dict(_, _) is declared in module dict), but
should be considered different when forwarding args.
|
|
* maint:
dialyzer: Fix a crash
|
|
|
|
|
|
* maint:
kernel: Correct contracts and a bug in group_history
stdlib: Correct contracts
dialyzer: Optimize handling of a lot of warnings
Conflicts:
lib/kernel/src/erl_boot_server.erl
|
|
If the number of warnings is huge the '--'/2 operator is slow.
|
|
This commit adds a new syntax for retrieving the stacktrace
without calling erlang:get_stacktrace/0. That allow us to
deprecate erlang:get_stacktrace/0 and ultimately remove it.
The problem with erlang:get_stacktrace/0 is that it can keep huge
terms in a process for an indefinite time after an exception. The
stacktrace can be huge after a 'function_clause' exception or a failed
call to a BIF or operator, because the arguments for the call will be
included in the stacktrace. For example:
1> catch abs(lists:seq(1, 1000)).
{'EXIT',{badarg,[{erlang,abs,
[[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20|...]],
[]},
{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,674}]},
{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,431}]},
{shell,exprs,7,[{file,"shell.erl"},{line,687}]},
{shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]},
{shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}]}}
2> erlang:get_stacktrace().
[{erlang,abs,
[[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,
23,24|...]],
[]},
{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,674}]},
{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,431}]},
{shell,exprs,7,[{file,"shell.erl"},{line,687}]},
{shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]},
{shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}]
3>
We can extend the syntax for clauses in try/catch to optionally bind
the stacktrace to a variable.
Here is an example using the current syntax:
try
Expr
catch C:E ->
Stk = erlang:get_stacktrace(),
.
.
.
In the new syntax, it would look like:
try
Expr
catch
C:E:Stk ->
.
.
.
Only a variable (not a pattern) is allowed in the stacktrace position,
to discourage matching of the stacktrace. (Matching would also be
expensive, because the raw format of the stacktrace would have to be
converted to the cooked form before matching.)
Note that:
try
Expr
catch E ->
.
.
.
is a shorthand for:
try
Expr
catch throw:E ->
.
.
.
If the stacktrace is to be retrieved for a throw, the 'throw:'
prefix must be explicitly included:
try
Expr
catch throw:E:Stk ->
.
.
.
|
|
Avoid some ETS-lookups. Marginal speed-ups.
|
|
|
|
* maint:
dialyzer: Improve a warning
dialyzer: Fix a weird warning
dialyzer: Fix an opaque bug
dialyzer: Minor fix
Conflicts:
lib/dialyzer/src/dialyzer_dataflow.erl
|
|
An opaque bug that would crash Dialyzer has been fixed.
The bug was reported by Nick Marino.
|
|
|
|
* maint:
dialyzer: Compact 'file' annotations in Core code
dialyzer: Try to reduce memory usage
dialyzer: Use less memory when translating contracts
dialyzer: Use maps instaed of dict
dialyzer: Use maps instead of dict for module contracts map
dialyzer: Compress a few more ETS tables
dialyzer: Optimize memory consumption
dialyzer: Reduce memory consumption during 'remote' phase
dialyzer: Update code for finding parallelism
compiler: Do not spawn process when dialyzing
dialyzer: Reduce ETS usage during the typesig phase
dialyzer: Optimize graph condensation
dialyzer: Do not send full PLTs as messages
|
|
File annotations {file, File} in Core Erlang code is replaced by
{file, FakeFile}, where FakeFile is "0", "1", ..., in order to save
memory. When a warning message is created, FakeFile is translated to
the original File (a bit awkward but easy to do).
The Core code stored in ETS tables needs less space, but more
important is that a less heap memory is used in the dataflow,
warnings, and typesig phases, allowing more parallelism.
|
|
|
|
* maint:
dialyzer: Substitute 'opacity' for 'opaqueness'
dialyzer: Improve a warning message
dialyzer: Improve a warning message
dialyzer: Correct a warnings message
|
|
Messages regarding guards with orelse/andalso could look
like "Clause guard cannot succeed. The variable A was matched
against the type any()". Now they look like as if or/and is
used: "Guard test is_integer(A::atom()) can never succeed".
|
|
Messages like "The attempt to match a term of type rec_api:f()
against the variable _ breaks the opaqueness of rec_adt:f()" now
look like "The attempt to match a term of type rec_adt:f()
against the record field 'f' with type rec_api:f() breaks the
opaqueness of the term".
|
|
The previous variable names can be generated by
projects like LFE and Elixir, leading to possible
conflicts. Our first to choice to solve such conflicts
was to use $ but that's not a valid variable name in core.
Therefore we picked @ which is currently supported and
still reduces the chance of conflicts.
|
|
Warnings about clauses that cannot match and are also compiler generated
are suppressed unless none of the clauses return.
This feature is useful for non-Erlang BEAM languages (such as Elixir)
that compile to Erlang and expand certain language constructs into case
statements. In that case, as long as the language construct can succeed,
these warnings are undesired and appear spurious to users that do not
check the Erlang code that their program expands into.
Thanks to José Valim for the test (slightly modified).
|
|
|
|
|
|
Dialyzer's "dataflow" module is using information from the callgraph to
determine which functions may be called at a particular call-site. Unfortunately
this information can include functions that are certainly not among the possible
choices. We don't want to emit warnings in such cases, so a "reasonable"
compromise is to stay silent if there are many possible funs and at least one of
them can succeed.
Bug reported by Dan Gudmundsson, test shrunk down by Magnus Lång.
|
|
Optimization: A few dictionaries are maps instead of dicts.
|
|
The assumption that 'try' nodes were only used to wrap entire guards is
no longer true.
We're still swallowing warnings when the handler returns successfully.
Unfortunately, bind_guard/5 would need to be refactored to return a new
state in order to generate those warnings.
|
|
Dialyzer relies heavily on the assumption that the type of a literal
that is used as a pattern is the type of any value that can match that
pattern. For maps, that is not true, and it was causing bad analysis
results. A new help function dialyzer_utils:refold_pattern/1 identifies
maps in literal patterns, and unfolds and labels them, allowing them to
be properly analysed.
|
|
|
|
|
|
Record field types have been modified due to commit 8ce35b2:
"Take out automatic insertion of 'undefined' from typed record fields".
|
|
|
|
|
|
Reported-by: Ali Sabil
|
|
In particular fix handling of records.
|
|
The -dialyzer() attribute can be used for suppressing warnings in a
module by specifying functions or warning options. It can also be used
for requesting warnings in a module.
|
|
* maint:
dialyzer, hipe: Fix a bug concerning is_record/2,3
|
|
Also fixed some cases where Dialyzer could crash due to reaching
system limits.
|
|
* maint:
[dialyzer] Correct a doc bug introduced in 0b041238
[dialyzer] Use the option 'dialyzer' to control the compiler
[dialyzer] Fix handling of literal records
|
|
This ticket is about records in Erlang code, and when to check the
fields against the (optional) types given when defining records.
Dialyzer operates on the Erlang Core format, where there are no trace
of records. The fix implemented is a Real Hack:
Given the new option 'dialyzer' erl_expand_records marks the line
number of records in a way that is undone by v3_core, which in turn
inserts annotations that can be recognized by Dialyzer.
|
|
The pre-defined types array(), dict(), digraph(), gb_set(), gb_tree(),
queue(), set(), and tid() have been removed.
|
|
Two steps are needed to make this work:
1) Avoid generating the additional "apply_constraint" in dialyzer_typesig by
reporting every function argument as a potential external function (patch on
dialyzer_dep).
This will produce correct success typings for all functions in the test case,
but dataflow would miss the key warnings that help identify the bugs.
2) Patch dialyzer_dataflow so that it uses the "handle just external" path as a
fallback whenever there are any external calls. As a result, if we have info
about some paths, then:
a) use the old "handle known apply" code to mark these functions as used and
b) ignore the generalized result and use the one found by typesig for the
return value of the apply itself.
|
|
The types array(), dict(), digraph(), gb_set(), gb_tree(), queue(),
set(), and tid() have been deprecated. They will be removed in OTP 18.0.
Instead the types array:array(), dict:dict(), digraph:graph(),
gb_set:set(), gb_tree:tree(), queue:queue(), sets:set(), and ets:tid()
can be used. (Note: it has always been necessary to use ets:tid().)
It is allowed in OTP 17.0 to locally re-define the types array(), dict(),
and so on.
New types array:array/1, dict:dict/2, gb_sets:set/1, gb_trees:tree/2,
queue:queue/1, and sets:set/1 have been added.
|
|
* bjorn/lc-warnings/OTP-11626:
dialyzer: Silence useless warnings about list comprehensions
|
|
Dialyzer will warn if the value of list comprehension is
ignored by putting it in a sequence like this:
[SomeSideEffect(E) || E <- Es],
ok
To avoid a warning, you'll have to write:
_ = [SomeSideEffect(E) || E <- Es],
ok
Most of the time, this warning is merely annoying because it does
not point out any real errors.
Kostis Sagonas suggested that by suppressing the warning for
list comprehension that return a list of a simple type (e.g. ['ok']),
there would be no warning for code such as:
[io:format("~p\n", [E]) || E <- Es],
ok
but there would be still be a warning for:
[file:close(Fd) || Fd <- Fds],
ok
because an error condition is ignored.
|
|
|
|
|
|
|
|
|
|
It is now OK to inspect and modify the internals of opaque types within
the scope of the module.
The contracts are used for decorating types with opaqueness when it is
harmless to do so. The opaqueness is propagated by the typesig module
and also by the dataflow module.
A lot of details have been fixed or updated. In particular the modules
erl_types and erl_bif_types have been modified extensively.
The version in vsn.mk has been updated to 2.7. The reason is a
modification of #opaque{} in erl_types.
Dialyzer seems to be about five percent slower than it used to be.
|