diff options
author | Björn Gustavsson <[email protected]> | 2015-01-16 12:59:30 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-01-26 12:58:11 +0100 |
commit | eaa0596c7c6e33f21783aef5b44fb52db23fc9fe (patch) | |
tree | bdf97be4391bf5072b58716b31a0b87d73477444 /lib/compiler | |
parent | 3ed131a2708c4b44e5dba77ba923a3f3ae28f011 (diff) | |
download | otp-eaa0596c7c6e33f21783aef5b44fb52db23fc9fe.tar.gz otp-eaa0596c7c6e33f21783aef5b44fb52db23fc9fe.tar.bz2 otp-eaa0596c7c6e33f21783aef5b44fb52db23fc9fe.zip |
lc_SUITE: Add shadow/1
Diffstat (limited to 'lib/compiler')
-rw-r--r-- | lib/compiler/test/lc_SUITE.erl | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/compiler/test/lc_SUITE.erl b/lib/compiler/test/lc_SUITE.erl index b40431c246..6b3472b37b 100644 --- a/lib/compiler/test/lc_SUITE.erl +++ b/lib/compiler/test/lc_SUITE.erl @@ -22,7 +22,7 @@ init_per_group/2,end_per_group/2, init_per_testcase/2,end_per_testcase/2, basic/1,deeply_nested/1,no_generator/1, - empty_generator/1,no_export/1]). + empty_generator/1,no_export/1,shadow/1]). -include_lib("test_server/include/test_server.hrl"). @@ -38,7 +38,8 @@ groups() -> deeply_nested, no_generator, empty_generator, - no_export + no_export, + shadow ]}]. init_per_suite(Config) -> @@ -186,6 +187,18 @@ no_export(Config) when is_list(Config) -> [] = [ _X = a || false ] ++ [ _X = a || false ], ok. +%% Test that variables in list comprehensions are +%% correctly shadowed. + +shadow(Config) when is_list(Config) -> + Shadowed = nomatch, + _ = id(Shadowed), %Eliminate warning. + L = [{Shadowed,Shadowed+1} || Shadowed <- lists:seq(7, 9)], + [{7,8},{8,9},{9,10}] = id(L), + [8,9] = id([Shadowed || {_,Shadowed} <- id(L), + Shadowed < 10]), + ok. + id(I) -> I. fc(Args, {'EXIT',{function_clause,[{?MODULE,_,Args,_}|_]}}) -> ok; |