aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/ms_transform_SUITE.erl
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2011-10-20 14:40:09 +0200
committerHenrik Nord <[email protected]>2011-10-20 14:40:13 +0200
commit896c1c7d262790d71019a583d880ee384e357167 (patch)
treec1ddd1029caf04a8078e892913727f4bf9237973 /lib/stdlib/test/ms_transform_SUITE.erl
parent45b4d5309e0686cc5fa28506de76f75b598bbd95 (diff)
parent29610af8d3db844568cffc4218f79fc68bfd8094 (diff)
downloadotp-896c1c7d262790d71019a583d880ee384e357167.tar.gz
otp-896c1c7d262790d71019a583d880ee384e357167.tar.bz2
otp-896c1c7d262790d71019a583d880ee384e357167.zip
Merge branch 'hl/fix-ms_transform-scope-warn'
* hl/fix-ms_transform-scope-warn: ms_transform: Fix incorrect `variable shadowed' warnings OTP-9646
Diffstat (limited to 'lib/stdlib/test/ms_transform_SUITE.erl')
-rw-r--r--lib/stdlib/test/ms_transform_SUITE.erl45
1 files changed, 44 insertions, 1 deletions
diff --git a/lib/stdlib/test/ms_transform_SUITE.erl b/lib/stdlib/test/ms_transform_SUITE.erl
index 4e5df12798..c9688354b1 100644
--- a/lib/stdlib/test/ms_transform_SUITE.erl
+++ b/lib/stdlib/test/ms_transform_SUITE.erl
@@ -39,6 +39,7 @@
-export([float_1_function/1]).
-export([action_function/1]).
-export([warnings/1]).
+-export([no_warnings/1]).
-export([init_per_testcase/2, end_per_testcase/2]).
init_per_testcase(_Func, Config) ->
@@ -55,7 +56,7 @@ all() ->
[from_shell, basic_ets, basic_dbg, records,
record_index, multipass, bitsyntax, record_defaults,
andalso_orelse, float_1_function, action_function,
- warnings, top_match, old_guards, autoimported,
+ warnings, no_warnings, top_match, old_guards, autoimported,
semicolon].
groups() ->
@@ -155,6 +156,34 @@ warnings(Config) when is_list(Config) ->
compile_ww(Prog7),
ok.
+no_warnings(suite) ->
+ [];
+no_warnings(doc) ->
+ ["Check that variables bound in other function clauses don't generate "
+ "warning"];
+no_warnings(Config) when is_list(Config) ->
+ ?line setup(Config),
+ Prog = <<"tmp(X) when X > 100 ->\n",
+ " Y=X,\n"
+ " Y;\n"
+ "tmp(X) ->\n"
+ " ets:fun2ms(fun(Y) ->\n"
+ " {X, 3*Y}\n"
+ " end)">>,
+ ?line [] = compile_no_ww(Prog),
+
+ Prog2 = <<"tmp(X) when X > 100 ->\n",
+ " Y=X,\n"
+ " Y;\n"
+ "tmp(X) when X < 200 ->\n"
+ " ok;\n"
+ "tmp(X) ->\n"
+ " ets:fun2ms(fun(Y) ->\n"
+ " {X, 3*Y}\n"
+ " end)">>,
+ ?line [] = compile_no_ww(Prog2),
+ ok.
+
andalso_orelse(suite) ->
[];
andalso_orelse(doc) ->
@@ -842,6 +871,20 @@ compile_ww(Records,Expr) ->
nowarn_unused_record]),
Wlist.
+compile_no_ww(Expr) ->
+ Prog = <<
+ "-module(tmp).\n",
+ "-include_lib(\"stdlib/include/ms_transform.hrl\").\n",
+ "-export([tmp/1]).\n\n",
+ Expr/binary,".\n">>,
+ FN=temp_name(),
+ file:write_file(FN,Prog),
+ {ok,Forms} = epp:parse_file(FN,"",""),
+ {ok,tmp,_Bin,Wlist} = compile:forms(Forms,[return_warnings,
+ nowarn_unused_vars,
+ nowarn_unused_record]),
+ Wlist.
+
do_eval(String) ->
{done,{ok,T,_},[]} = erl_scan:tokens(
[],