Age | Commit message (Collapse) | Author |
|
|
|
erl_lint:icrt_export/4 has been rewritten to make the code really
follow the scoping rules of Erlang, and not just in most situations
by accident.
* The function should not depend on calling unused_vars/3 because that
function does not return variables which begins with an underscore,
something that only matters when emitting warnings. This could cause
a compiler crash if such a variable was reused afterwards.
* The variable tables from each clause are first merged together,
lists:merge/1 is safe to use because they are orddicts and thus
already sorted. This list is then traversed parallelly to the old
variable table, again taking advantage of their sorted order.
* The function does not emit warnings itself, there is no need to pass
around the lint state. In the same vein, vtunsafe/3 has been rewritten
to do more things by itself, given that all of its calls were similar.
Finally, compiled-out code has been removed.
* This reverts the code in 9ce148b1059e4da746a11f1d80a653340216c468,
which fixed the compiler crash and made erl_lint remember unsafe
variables, but forget about unused variables in the process.
* Other places of the code which relied on the old clunky behaviour were
also updated: unused and unsafe old variables are forgotten when
merging fun clauses and boolean shortcircuiting operators do not rely
on icrt_export/3 anymore.
|
|
The pre-defined types array(), dict(), digraph(), gb_set(), gb_tree(),
queue(), set(), and tid() have been removed.
|
|
Use F/A rather than M:F/A for local functions.
|
|
Types are represented by quadruples {type, LINE, Name, Args},
but maps were represented by five-tuples
{type, LINE, map_field_assoc, Dom, Range}.
Note: this is *not* about the quadruples used for representing
expressions, {map_field_assoc,L,K,V}.
|
|
sys_pre_expand used to crash. There is no known reason to
allow -callback attributes with explicit module.
|
|
product/_, union/_, range/2 as well as tuple/N (N > 0), map/N (N > 0),
atom/1, integer/1, binary/2, record/_, and 'fun'/_ can now be used as
type names.
|
|
|
|
When redefining and exporting the type map() erl_lint erroneously
emitted an error. This bug has been fixed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Only values are valid key expressions.
|
|
erl_lint has since R13B emitted warnings whenever any of the types
arity(), bitstring(), iodata(), or boolean() were re-defined. Now
errors are emitted instead.
|
|
Since Erlang/OTP R16B the linter has not emitted warnings when
built-in types were re-defined. This bug has been fixed.
Thanks to Roberto Aloi for reporting the bug.
|
|
* nox/maps-improve-erl_lint:
Improve linting of map expressions
|
|
* nox/compiler/lint-shortcircuit-ops:
Properly lint shortcircuiting operators
|
|
The deprecation of the built-in types dict/0 and so on had as
side-effect that it was impossible to switch to dict:dict/2 and so on
without getting warnings either in the the previous release (R16B) or
the current one (17.0).
By including the attribute
-compile(nowarn_deprecated_type).
in an Erlang source file warnings about deprecated types can be
avoided in 17.0.
The option can also be given as a compiler flag:
erlc +nowarn_deprecated_type file.erl
|
|
|
|
Map fields are put in their own function instead of being clauses of expr/3.
Also, invalid map construction expressions now emit one error per ':=' field,
at the location of said field instead of one for the whole expression,
furthermore, such warnings do not stop linting of their key and value
expressions anymore. Ill-formed maps constructions are now also properly
detected in guard expressions.
|
|
Shortcircuiting operators are not real functions and can't be used as
such with erlang:'andalso'(...) and erlang:'orelse'(...).
Reported-by: Ulf Norell
|
|
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.
|
|
* josevalim/suppress-all-auto-imports:
Allow all auto imports to be suppressed at once
OTP-11682
|
|
|
|
In the current iteration of Maps we should deny *any* variables in
Map keys.
|
|
Update erlang lint and syntax expand for #{ K := V }
|
|
|
|
Reported-by: Michele Miron
|
|
This adds optional names to fun expressions. A named fun expression
is parsed as a tuple `{named_fun,Loc,Name,Clauses}` in erl_parse.
If a fun expression has a name, it must be present and be the same in
every of its clauses. The function name shadows the environment of the
expression shadowing the environment and it is shadowed by the
environment of the clauses' arguments. An unused function name triggers
a warning unless it is prefixed by _, just as every variable.
Variable _ is allowed as a function name.
It is not an error to put a named function in a record field default
value.
When transforming to Core Erlang, the named fun Fun is changed into
the following expression:
letrec 'Fun'/Arity =
fun (Args) ->
let <Fun> = 'Fun'/Arity
in Case
in 'Fun'/Arity
where Args is the list of arguments of 'Fun'/Arity and Case the
Core Erlang expression corresponding to the clauses of Fun.
This transformation allows us to entirely skip any k_var to k_local
transformation in the fun's clauses bodies.
|
|
This patch introduces the no_auto_import attribute:
-compile(no_auto_import).
Useful for code generation tools that always use the
qualified function names and want to avoid the auto
imported functions clashing with local ones.
Implementation wise, we chose to have a special flag
'all' to avoid doing many set lookups when checking for
suppression.
|
|
Conflicts:
bootstrap/lib/stdlib/ebin/erl_lint.beam
|
|
When reporting a field redefinition in a record, erl_lint can forget
about some old unused variables.
f() -> X = 1, #r{a=foo,a=bar,a=qux}.
|
|
Variables used in the body of a try expression were marked as unsafe
*and* used, which makes no sense as an unsafe variable can't be used.
Function vtsubtract/2 is used to forget usage of such unsafe variables.
Reported-by: Paul Davis
|
|
When analyzing complex expressions (i.e. comprehensions, cases, tries,
ifs and receives), erl_lint does not forget about old unused variables
when returning the updated variable table. This causes a bug where old
unused variables are not recorded as such:
t(X, Y) ->
#r{a=[ K || K <- Y ],b=[ K || K <- Y ]}.
As erl_lint uses vtmerge_pat/2 to merge the results of the analysis of
the two list comprehensions, X is marked as used and the warning is not
emitted.
The function vtmerge_pat/2 is used instead of the similar vtmerge/2
which does not mark multiple occurrences of a variable as usage to
handle cases like the following one:
t(X, Y) ->
#r{a=A=X,b=A=Y}.
Other simpler expressions like conses, tuples and external fun
references do not correctly follow this behaviour, e.g. A is not marked
as used in the following code:
t(X, Y) ->
{A=X,A=Y}.
This commit fixes both issues and makes erl_lint not return old unused
variables in updated tables and makes all compound expressions use
vtmerge_pat/2.
Reported-by: Anders Ramsell
|
|
* maint:
Fix a bug in the linter regarding the 'fun M:F/A' construct
|
|
If the fun M:F/A construct was used erroneously the linter could
crash.
Thanks to Mikhail Sobolev for reporting the bug.
|
|
It makes no sense to be able to do `<<...,Rest/binary>> <= ...` in a
comprehension. The related Dialyzer test is removed.
|
|
|
|
The default_types() in erl_lint returned a dictionary
with all default types. However, calculating this dict
was expensive and we actually didn't use the default
values in this dictionary.
This patch replaces the dictionary use for one function
that checks if the type is a default type or not,
and remove the bits that checked explicitly for those
default types when iterating the dictionary.
|
|
The modifier 'l' can be used for turning off the string recognition of
~p and ~P.
|
|
|
|
|
|
There are currently no keywords reserved for the future.
|
|
All guards BIFs are auto-imported. That can be verified like this:
[] = [{F,A} || {erlang,F,A} <- erlang:system_info(snifs),
erl_internal:guard_bif(F, A),
not erl_internal:bif(F, A)]
Therefore, calling a guard BIF in a guard without a module name
is always allowed (provided that there is not a local function or
an import with the same name), and therefore we can remove the
error reporting code. But keep an assertion so that we will find
out if any non-auto-imported guard BIFs are added in the future.
|
|
* bjorn/remove-tuple-funs/OTP-10170:
erl_lint: Removes vestiges of tuple fun support
|
|
* bjorn/remove-packages/OTP-10348:
erl_lint: Remove vestiges of package support
shell: Remove vestiges of package support
|
|
|