Age | Commit message (Collapse) | Author |
|
erl_lint:format_error/1 would crash with a function error if
conflicting types were given. That was most easily noticed in the
shell:
Eshell V7.0.3 (abort with ^G)
1> <<0/integer-binary>>.
*** ERROR: Shell process terminated! ***
Noticed-by: Aleksei Magusev
|
|
|
|
* josevalim/jv-annotate-form-type:
Annotate used types in erl_lint
OTP-12800
|
|
This is a follow up to commit b5ee5c6.
Similar to function calls, we also need to annotate used types
on call site since this information is used later on when showing
undefined type errors.
Notice we don't need to annotate the type export because
it is an attribute and those are always properly annotated.
|
|
* josevalim/jv-annotate-form:
Only annotate forms when linting in the compiler
OTP-12772
|
|
A lot of time spent on linting is due to eval_file_attribute/2
function that recursively traverses all the AST, annotating
the file name on the AST nodes. This traversal happens so
it is easier to add errors and warnings later on by simply
introspecting the node.
This patch changes eval_file_attribute/2 to only annotate
forms (i.e. attributes and functions) and rely on the #lint
record to keep the proper file information (which it already
did before this patch).
To summarize, both pre scan and pos scan will use the annotated
file attribute in forms, however form/2 already maintains the
proper file in #lint, which we pass around when retrieving the
location information.
After this patch, linting of a regular erlang module with 500LOC
became twice faster when measured with eprof.
|
|
Parameterized modules were removed in cdf8060868575, but a few
vestiges still remained in erl_lint.
|
|
When compiling parser files, because they rely heavily
on inline annotations, retrieving the nowarn_bif_clash
information from the compiler options is expensive.
This patch stores nowarn_bif_clash in the lint record.
By using erlc +'{eprof,lint_module}' when compiling the
erlang parser, we noticed the time spent on
nowarn_function/2 reduced from 30% to 0.01%.
|
|
|
|
* nox/stdlib/erl_lint-maps/OTP-12515:
Properly lint map expressions in erl_lint
|
|
* nox/stdlib/erl_lint-expr_list:
Remove a few superfluous vt operations in erl_lint
|
|
Given any Vt1 and Vt2 values, vtmerge(vtnew(Vt1, Vt2), vtold(Vt1, Vt2)) is always
equal to Vt1.
|
|
The returned variable table when linting a map expression shouldn't include
variables that didn't appear in the expression.
Reported-By: Alexei Sholik
|
|
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.
|
|
Robert has OK'ed the removal of the token ':-'.
|
|
* egil/maps/variable-keys/OTP-12218: (22 commits)
compiler: Update test for Maps aliasing
compiler: Properly support Map aliasing
compiler: Refactor Map pairs aliasing
compiler: Fix harmless need_heap error for Maps
stdlib: Update Map tests
stdlib: Use environment bindings for Maps keys in erl_eval matching
debugger: Update Map tests
compiler: Update Map tests
compiler: Fix v3_core Maps pair chains
compiler: Use expressions in core patterns
compiler: Use variables in Map cerl inliner
compiler: Reintroduce binary limit for Map keys
compiler: Shameless v3_core hack for variables
compiler: Use variables in Map beam assmebler
compiler: Use variables in Map kernel pass
compiler: Use variables in Map core pass
compiler: Normalize unary ops on Maps key literals
stdlib: Update Map tests
stdlib: erl_lint Map key variables
compiler: Maps are always patterns never values in matching
...
|
|
* nox/fix-exporting-rules/OTP-12186:
Rewrite merge of clause variable tables (in case, try, etc)
|
|
|
|
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.
|