aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/erl_eval.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2017-12-19 15:30:17 +0100
committerHans Bolinder <[email protected]>2018-01-09 16:39:21 +0100
commitcf3b2c808e8b7eccd39bedbb9c62432f7da5ca59 (patch)
tree1339d141e9165ef4eae174a44b3b734287c983c8 /lib/stdlib/src/erl_eval.erl
parent8171c997f02e8b54b3f238d5652345fe6d77523b (diff)
downloadotp-cf3b2c808e8b7eccd39bedbb9c62432f7da5ca59.tar.gz
otp-cf3b2c808e8b7eccd39bedbb9c62432f7da5ca59.tar.bz2
otp-cf3b2c808e8b7eccd39bedbb9c62432f7da5ca59.zip
stdlib: Add check of stacktrace variable to erl_eval
Some of the functions of the erl_eval module do not call the Erlang code linter, so they need to explicitly check that the newly introduced stacktrace variable is not bound.
Diffstat (limited to 'lib/stdlib/src/erl_eval.erl')
-rw-r--r--lib/stdlib/src/erl_eval.erl22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/stdlib/src/erl_eval.erl b/lib/stdlib/src/erl_eval.erl
index 489f65290a..4ee11383da 100644
--- a/lib/stdlib/src/erl_eval.erl
+++ b/lib/stdlib/src/erl_eval.erl
@@ -904,9 +904,9 @@ if_clauses([], _Bs, _Lf, _Ef, _RBs) ->
%% try_clauses(Body, CaseClauses, CatchClauses, AfterBody, Bindings,
%% LocalFuncHandler, ExtFuncHandler, RBs)
-%% When/if variable bindings between the different parts of a
-%% try-catch expression are introduced this will have to be rewritten.
+
try_clauses(B, Cases, Catches, AB, Bs, Lf, Ef, RBs) ->
+ check_stacktrace_vars(Catches, Bs),
try exprs(B, Bs, Lf, Ef, none) of
{value,V,Bs1} when Cases =:= [] ->
ret_expr(V, Bs1, RBs);
@@ -919,7 +919,6 @@ try_clauses(B, Cases, Catches, AB, Bs, Lf, Ef, RBs) ->
end
catch
Class:Reason:Stacktrace when Catches =:= [] ->
- %% Rethrow
erlang:raise(Class, Reason, Stacktrace);
Class:Reason:Stacktrace ->
V = {Class,Reason,Stacktrace},
@@ -937,6 +936,23 @@ try_clauses(B, Cases, Catches, AB, Bs, Lf, Ef, RBs) ->
end
end.
+check_stacktrace_vars([{clause,_,[{tuple,_,[_,_,STV]}],_,_}|Cs], Bs) ->
+ case STV of
+ {var,_,V} ->
+ case binding(V, Bs) of
+ {value, _} ->
+ erlang:raise(error, stacktrace_bound, ?STACKTRACE);
+ unbound ->
+ check_stacktrace_vars(Cs, Bs)
+ end;
+ _ ->
+ erlang:raise(error,
+ {illegal_stacktrace_variable,STV},
+ ?STACKTRACE)
+ end;
+check_stacktrace_vars([], _Bs) ->
+ ok.
+
%% case_clauses(Value, Clauses, Bindings, LocalFuncHandler, ExtFuncHandler,
%% RBs)