aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/erl_lint.erl
AgeCommit message (Collapse)Author
2015-12-15stdlib: Remove undocumented function specification syntaxHans Bolinder
The syntax -spec/callback F/A :: FunctionType; has been removed. No deprecation was deemed necessary.
2015-12-04Merge branch 'maint'Björn Gustavsson
* maint: Extend erl_lint:format_error/1 to handle bittype mismatches erl_lint_SUITE: Add smoke test of format_error/1
2015-12-03Extend erl_lint:format_error/1 to handle bittype mismatchesBjörn Gustavsson
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
2015-11-27Forbid bytes modifier for unsized part of binary generatorAleksei Magusev
This type modifier was missed in 90efeaf21147505b1e8207822e606027f94183cc.
2015-09-15stdlib: Remove deprecated functions in erl_parse and erl_scanHans Bolinder
The recently added module erl_anno can no longer handle negative line numbers.
2015-06-18Change license text to APLv2Bruce Yinhe
2015-06-02Merge branch 'josevalim/jv-annotate-form-type'Henrik Nord
* josevalim/jv-annotate-form-type: Annotate used types in erl_lint OTP-12800
2015-05-27Annotate used types in erl_lintJosé Valim
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.
2015-05-26Merge branch 'josevalim/jv-annotate-form'Henrik Nord
* josevalim/jv-annotate-form: Only annotate forms when linting in the compiler OTP-12772
2015-05-22Only annotate forms when linting in the compilerJosé Valim
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.
2015-05-21Remove final (?) vestiges of support for parameterized modulesBjörn Gustavsson
Parameterized modules were removed in cdf8060868575, but a few vestiges still remained in erl_lint.
2015-05-14Cache nowarn_bif_clash functions in erl_lintJosé Valim
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%.
2015-04-30stdlib: Use module erl_annoHans Bolinder
2015-02-25Merge branch 'nox/stdlib/erl_lint-maps/OTP-12515'Björn Gustavsson
* nox/stdlib/erl_lint-maps/OTP-12515: Properly lint map expressions in erl_lint
2015-02-25Merge branch 'nox/stdlib/erl_lint-expr_list'Björn Gustavsson
* nox/stdlib/erl_lint-expr_list: Remove a few superfluous vt operations in erl_lint
2015-02-22Remove a few superfluous vt operations in erl_lintAnthony Ramine
Given any Vt1 and Vt2 values, vtmerge(vtnew(Vt1, Vt2), vtold(Vt1, Vt2)) is always equal to Vt1.
2015-02-16Properly lint map expressions in erl_lintAnthony Ramine
The returned variable table when linting a map expression shouldn't include variables that didn't appear in the expression. Reported-By: Alexei Sholik
2015-01-14dialyzer: Introduce module local suppression of warningsHans Bolinder
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.
2014-11-20stdlib: remove the last traces of Mnemosyne RulesHans Bolinder
Robert has OK'ed the removal of the token ':-'.
2014-10-03Merge branch 'egil/maps/variable-keys/OTP-12218'Björn-Egil Dahlberg
* 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 ...
2014-09-22Merge branch 'nox/fix-exporting-rules/OTP-12186'Marcus Arendt
* nox/fix-exporting-rules/OTP-12186: Rewrite merge of clause variable tables (in case, try, etc)
2014-08-22stdlib: erl_lint Map key variablesBjörn-Egil Dahlberg
2014-08-02Rewrite merge of clause variable tables (in case, try, etc)Anthony Ramine
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.
2014-05-05Remove pre-defined types dict(), digraph(), &cHans Bolinder
The pre-defined types array(), dict(), digraph(), gb_set(), gb_tree(), queue(), set(), and tid() have been removed.
2014-04-29[stdlib] Simplify some linter warnings about specsHans Bolinder
Use F/A rather than M:F/A for local functions.
2014-04-29Modify representation of the map typeHans Bolinder
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}.
2014-04-29Fix a -callback attribute bugHans Bolinder
sys_pre_expand used to crash. There is no known reason to allow -callback attributes with explicit module.
2014-04-29Allow more type namesHans Bolinder
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.
2014-04-28Introduce the attribute -optional_callbacks in the context of behavioursHans Bolinder
2014-04-16stdlib: Fix error message when exporting (redefined) map() typeHans Bolinder
When redefining and exporting the type map() erl_lint erroneously emitted an error. This bug has been fixed.
2014-04-03stdlib: Deny map keys defined as #{ .. := .. } in patternsBjörn-Egil Dahlberg
2014-03-24stdlib: warn if the type map() is redefinedHans Bolinder
2014-03-24stdlib: Add more types to epp and erl_lintHans Bolinder
2014-03-17stdlib: Accept records as Map keysBjörn-Egil Dahlberg
2014-03-17stdlib: Accept Maps as Map keysBjörn-Egil Dahlberg
2014-03-17stdlib: Move map type to proper definitionBjörn-Egil Dahlberg
2014-03-17stdlib: Properly lint map key expressionsBjörn-Egil Dahlberg
Only values are valid key expressions.
2014-03-07Emit errors when redefining arity(), bitstring(), iodata(), or boolean()Hans Bolinder
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.
2014-03-07stdlib: Emit linter warnings for redefined built-in typesHans Bolinder
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.
2014-03-06Merge branch 'nox/maps-improve-erl_lint'Björn-Egil Dahlberg
* nox/maps-improve-erl_lint: Improve linting of map expressions
2014-03-05Merge branch 'nox/compiler/lint-shortcircuit-ops'Björn Gustavsson
* nox/compiler/lint-shortcircuit-ops: Properly lint shortcircuiting operators
2014-03-04Introduce compiler option 'nowarn_deprecated_type'Hans Bolinder
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
2014-03-04Improve message about deprecated built-in typesHans Bolinder
2014-03-04Improve linting of map expressionsAnthony Ramine
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.
2014-03-01Properly lint shortcircuiting operatorsAnthony Ramine
Shortcircuiting operators are not real functions and can't be used as such with erlang:'andalso'(...) and erlang:'orelse'(...). Reported-by: Ulf Norell
2014-02-23Deprecate pre-defined built-in typesHans Bolinder
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.
2014-02-10Merge branch 'josevalim/suppress-all-auto-imports'Henrik Nord
* josevalim/suppress-all-auto-imports: Allow all auto imports to be suppressed at once OTP-11682
2014-01-28dialyzer,hipe,stdlib: Add Maps understanding to DialyzerBjörn-Egil Dahlberg
2014-01-28stdlib: Deny variables as keys and disallow ':=' in map constructionBjörn-Egil Dahlberg
In the current iteration of Maps we should deny *any* variables in Map keys.
2014-01-28Update erl_lint, erl_expand_records, sys_pre_expand for MapsBjörn-Egil Dahlberg
Update erlang lint and syntax expand for #{ K := V }