diff options
author | Björn Gustavsson <[email protected]> | 2017-09-06 13:06:48 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-09-06 13:16:45 +0200 |
commit | c00141b1e368bc41d9628fddbc01a6553ca14479 (patch) | |
tree | 96ae8470cd8542b8965156df5c021346b348b6fd /lib | |
parent | 7394b41b9f254c7f83d508cfc615bd1d63a84507 (diff) | |
download | otp-c00141b1e368bc41d9628fddbc01a6553ca14479.tar.gz otp-c00141b1e368bc41d9628fddbc01a6553ca14479.tar.bz2 otp-c00141b1e368bc41d9628fddbc01a6553ca14479.zip |
Eliminate incorrect get_stacktrace/0 warning
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stdlib/src/erl_lint.erl | 4 | ||||
-rw-r--r-- | lib/stdlib/test/erl_lint_SUITE.erl | 22 |
2 files changed, 23 insertions, 3 deletions
diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index 65ba343368..9cd4727dc3 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -3238,13 +3238,13 @@ icrt_clauses(Cs, In, Vt, St0) -> icrt_clauses(Cs, Vt, St) -> mapfoldl(fun (C, St0) -> icrt_clause(C, Vt, St0) end, St, Cs). -icrt_clause({clause,_Line,H,G,B}, Vt0, St0) -> +icrt_clause({clause,_Line,H,G,B}, Vt0, #lint{catch_scope=Scope}=St0) -> {Hvt,Binvt,St1} = head(H, Vt0, St0), Vt1 = vtupdate(Hvt, Binvt), {Gvt,St2} = guard(G, vtupdate(Vt1, Vt0), St1), Vt2 = vtupdate(Gvt, Vt1), {Bvt,St3} = exprs(B, vtupdate(Vt2, Vt0), St2), - {vtupdate(Bvt, Vt2),St3}. + {vtupdate(Bvt, Vt2),St3#lint{catch_scope=Scope}}. icrt_export(Vts, Vt, {Tag,Attrs}, St) -> {_File,Loc} = loc(Attrs, St), diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl index cb1cceb8db..b76bece07f 100644 --- a/lib/stdlib/test/erl_lint_SUITE.erl +++ b/lib/stdlib/test/erl_lint_SUITE.erl @@ -4104,7 +4104,27 @@ get_stacktrace(Config) -> [], {warnings,[{4,erl_lint,{get_stacktrace,wrong_part_of_try}}, {13,erl_lint,{get_stacktrace,after_try}}, - {22,erl_lint,{get_stacktrace,after_try}}]}}], + {22,erl_lint,{get_stacktrace,after_try}}]}}, + {multiple_catch_clauses, + <<"maybe_error(Arg) -> + try 5 / Arg + catch + error:badarith -> + _Stacktrace = erlang:get_stacktrace(), + try io:nl() + catch + error:_ -> io:format('internal error') + end; + error:badarg -> + _Stacktrace = erlang:get_stacktrace(), + try io:format(qwe) + catch + error:_ -> io:format('internal error') + end + end. + ">>, + [], + []}], run(Config, Ts), ok. |