aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
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/test
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/test')
-rw-r--r--lib/stdlib/test/erl_eval_SUITE.erl20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/stdlib/test/erl_eval_SUITE.erl b/lib/stdlib/test/erl_eval_SUITE.erl
index 3c95b5781e..8eb85cab8e 100644
--- a/lib/stdlib/test/erl_eval_SUITE.erl
+++ b/lib/stdlib/test/erl_eval_SUITE.erl
@@ -1033,6 +1033,14 @@ otp_14826(_Config) ->
backtrace_check("try a of b -> bar after foo end.",
{try_clause,a},
[{erl_eval,try_clauses,8}]),
+ check(fun() -> X = try foo:bar() catch A:B:C -> {A,B} end, X end,
+ "try foo:bar() catch A:B:C -> {A,B} end.",
+ {error, undef}),
+ backtrace_check("C = 4, try foo:bar() catch A:B:C -> {A,B,C} end.",
+ stacktrace_bound,
+ [{erl_eval,check_stacktrace_vars,2},
+ {erl_eval,try_clauses,8}],
+ none, none),
backtrace_catch("catch (try a of b -> bar after foo end).",
{try_clause,a},
[{erl_eval,try_clauses,8}]),
@@ -1040,6 +1048,18 @@ otp_14826(_Config) ->
badarith,
[{erlang,'/',[1,0],[]},
{erl_eval,do_apply,6}]),
+ Es = [{'try',1,[{call,1,{remote,1,{atom,1,foo},{atom,1,bar}},[]}],
+ [],
+ [{clause,1,[{tuple,1,[{var,1,'A'},{var,1,'B'},{atom,1,'C'}]}],
+ [],[{tuple,1,[{var,1,'A'},{var,1,'B'},{atom,1,'C'}]}]}],[]}],
+ try
+ erl_eval:exprs(Es, [], none, none),
+ ct:fail(stacktrace_variable)
+ catch
+ error:{illegal_stacktrace_variable,{atom,1,'C'}}:S ->
+ [{erl_eval,check_stacktrace_vars,2,_},
+ {erl_eval,try_clauses,8,_}|_] = S
+ end,
backtrace_check("{1,1} = {A = 1, A = 2}.",
{badmatch, 1},
[erl_eval, {lists,foldl,3}]),