aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/erl_lint_SUITE.erl
AgeCommit message (Collapse)Author
2018-01-22stdlib: Correct contractsHans Bolinder
2017-09-06Eliminate incorrect get_stacktrace/0 warningBjörn Gustavsson
There could be a false warning for erlang:get_stacktrace/0 being outside a try block when it was actually inside a try block. https://bugs.erlang.org/browse/ERL-478
2017-06-22stdlib: Accept all nowarn_deprecated_function optionsHans Bolinder
The check of bad nowarn_deprecated_function tags in -compile attributes often made it impossible to compile modules with the warnings_as_errors option in two consecutive releases.
2017-06-09stdlib: Add more checks of module names to the linterHans Bolinder
Unicode atoms are handled better by the Erlang code linter. Module names are checked for character codes greater than 255. This means that modules invoked after the linter can assume that module names have only Latin-1 characters.
2017-05-22stdlib: Warn for bad type variables of parameterized typesHans Bolinder
The linter emits warnings about using '_' as type variable in parameterized types.
2017-05-12Warn for potentially unsafe use of get_stacktrace/0Björn Gustavsson
erlang:get_stacktrace/0 returns the stacktrace for the latest exception. The problem is that the stacktrace is kept until the next exception occurs. If the last exception was a 'function_clause' or a 'badarg', the arguments for the call are also kept forever. The arguments can be terms of any size (potentially huge). In a future release, we would like to only allow erlang:get_stacktrace/0 from within a 'try' expression. That would make it possible to clear the stacktrace when the 'try' expression is exited. The 'catch' expression has no natural end where the stacktrace could be cleared. The stacktrace could be cleared at the end of the function that the 'catch' occurs in, but that would cause problems in the following scenario (from real life, but simplified): try ... catch _:_ -> io:format(...), io:format("~p\n", [erlang:get_stacktrace()]) end. %% In io.erl. format(Fmt, Args) -> Res = case ... of SomePattern -> catch... ...; SomeOtherPattern -> %% Output the formatted string here ... end, clear_stacktrace(), %% Inserted by compiler. Res. The call to io:format() would always clear the stacktrace before it could be retrieved. That problem could be solved by tightning the scope in which the stacktrace is kept, but the rules for how long erlang:get_stacktrace/0 would work would become complicated. Therefore, the solution we suggest for a future major release of OTP is that erlang:get_stacktrace/0 will return [] if it is called outside the 'catch' part of a 'try' expression. To help users prepare, introduce a warning when it is likely that erlang:get_stacktrace/0 will always return an empty list, for example in this code: catch error(foo), Stk = erlang:get_stacktrace() or in this code: try Expr catch _:_ -> ok end, Stk = erlang:get_stacktrace()
2017-04-24Merge branch 'zandra/stdlib/optional-callbacks/OTP-13801'Zandra Norman
* zandra/stdlib/optional-callbacks/OTP-13801: wx: make wx_object callbacks optional stdlib: Make gen_fsm callbacks optional stdlib: Make gen_event callbacks optional stdlib: Make gen_server callbacks optional
2017-04-21stdlib: Make gen_server callbacks optionalZandra Norman
2017-04-13stdlib: Add checks of the dialyzer attribute to the linterHans Bolinder
The same checks are also performed by the Dialyzer.
2017-03-21Merge branch 'ingela/corrct-otp-internal'Ingela Anderton Andin
* ingela/corrct-otp-internal: ssl, public_key, crypto: Change deprecated to removed
2017-03-20ssl, public_key, crypto: Change deprecated to removedIngela Anderton Andin
2017-03-16Don't allow module names with non-latin1 charactersBjörn Gustavsson
In OTP 20, all Unicode characters are allowed in atoms. However, we have decided that we will not allow non-latin1 characters in module names in OTP 20. This restriction may be lifted in a future major release of OTP. Enforce the restriction in erl_lint, so that it will be a compilation error to have a module name containing non-latin1 characters. That means that tools such as debugger, xref, dialyzer, syntax_tools, and so on, do not have to be modified to handle non-latin1 module names.
2017-03-08stdlib: Fix handling of locations and annotationsHans Bolinder
2017-01-25Update test cases for erlang:hash/2 removalBjörn-Egil Dahlberg
2017-01-13Merge branch 'hasse/stdlib/check_type_constraints/OTP-14070/PR-1214'Hans Bolinder
* hasse/stdlib/check_type_constraints/OTP-14070/PR-1214: stdilb: Check for bad type constraints in function types
2016-12-01stdilb: Check for bad type constraints in function typesHans Bolinder
The parser recognizes the 'is_subtype(V, T)' syntax for constraints, and of course the new 'V :: T' syntax, but other variants result in an error message. Up to now, the parser and linter have let badly formed constraints through, and relied upon Dialyzer to emit warnings. is_subtype/2 cannot easily be taken out from the parser. Not only would we need find a way to emit a (linter) warning, but there also needs to be an option for suppressing the linter warning as compilation with +warnings_as_errors has to work. (Notice that the abstract format representation for 'V :: T' is the same as for 'is_subtype(V, T)'.) This correction was triggered by an email from Robert, and Kostis created pull request 1214 to provide a fix. However, Kostis' fix disallowed is_subtype() altogether, which breaks backward compatibility. As of Erlang/OTP 19.0 (ticket OTP-11879), the 'is_subtype(V, T)' is no longer documented.
2016-11-30stdlib test suite: fix uses of export_allRichard Carlsson
2016-11-29Make warn_export_all the defaultRichard Carlsson
2016-09-02Don't crash when obsolete guard overrides local functionBjörn Gustavsson
The compiler would crash in v3_codegen when trying to compile the following code: is_port(_) -> false. foo(P) when port(P) -> ok. We *could* have the compiler interpret the code as: is_port(_) -> false. foo(P) when erlang:is_port(P) -> ok. But that would encourage using the obsolete form of the guard tests. Note that the following code is illegal: is_port(_) -> false. foo(P) when is_port(P) -> ok. It produces the following diagnostic: call to local/imported function is_port/1 is illegal in guard Therefore, we should refuse to compile the code.
2016-05-07Fix deprecated warningsYuki Ito
In current deprecated warnings such as `crypto:rand_bytes/1 is deprecated and will be removed in in a future release; use crypto:strong_rand_bytes/1`, the word "in" is duplicated.
2016-05-02stdlib: Strengthen map pattern testsBjörn-Egil Dahlberg
2016-05-02stdlib: Add lint tests for parallel match of mapsBjörn-Egil Dahlberg
2016-05-02stdlib: Refactor erl_lint_SUITEBjörn-Egil Dahlberg
2016-04-18stdlib: The type map() is built-inHans Bolinder
2016-03-09Eliminate use of ?config() macroBjörn Gustavsson
2016-03-09Remove ?line macrosBjörn Gustavsson
While we are it, also re-ident the files.
2016-03-09Replace "%" with "%%" at the beginning of a lineBjörn Gustavsson
We want to re-ident the source files after having taken out all ?line macros. When re-indenting using Emacs, it's important that comments that should be at the beginning of a line (or follow the indentation of statements around it) must start with "%%".
2016-03-09Eliminate 'suite' and 'doc' clausesBjörn Gustavsson
2016-03-09Replace use of test_server:format/2 with io:format/2Björn Gustavsson
There is no practial difference.
2016-03-09Eliminate use of test_server:fail/0,1Björn Gustavsson
2016-03-09Modernize use of timetrapsBjörn Gustavsson
Either rely on the default 30 minutes timetrap, or set the timeout using the supported methods in common_test.
2016-02-18Merge branch 'bjorn/remove-test_server/OTP-12705'Björn Gustavsson
* bjorn/remove-test_server/OTP-12705: Remove test_server as a standalone application Erlang mode for Emacs: Include ct.hrl instead test_server.hrl Remove out-commented references to the test_server applications Makefiles: Remove test_server from include path and code path Eliminate use of test_server.hrl and test_server_line.hrl
2016-02-17stdlib: Let the linter detect old typed recordsHans Bolinder
2016-02-17Eliminate use of test_server.hrl and test_server_line.hrlBjörn Gustavsson
As a first step to removing the test_server application as as its own separate application, change the inclusion of test_server.hrl to an inclusion of ct.hrl and remove the inclusion of test_server_line.hrl.
2016-02-05Move record compilation errors to erl_lint_SUITEBjörn Gustavsson
The two bad record usage test cases in compile_SUITE do not belong there, as the errors are detected in erl_lint. Move the test to the erl_lint_SUITE.
2016-01-13Merge branch 'maint'Hans Bolinder
* maint: stdlib: Fix linter crash due to missing -module declaration Conflicts: lib/stdlib/test/erl_lint_SUITE.erl
2016-01-13stdlib: Fix linter crash due to missing -module declarationHans Bolinder
The Erlang Code Linter no longer crashes if there is a -deprecated() attribute but no -module() declaration. See also ERL-62 at bugs.erlang.org.
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-12-03erl_lint_SUITE: Add smoke test of format_error/1Björn Gustavsson
The test suite depended on the compiler to call erl_lint:format_error/1 to ensure that format_error/1 was covered. Unfortunately, though, if format_error/1 crashed the compiler would catch the exception so that the test suite would not notice it. Add a smoke test of format_error/1 that will crash if there is any problem with erl_lint:format_error/1.
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-04-30stdlib: Use module erl_annoHans Bolinder
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
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: Update Map testsBjö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.