diff options
author | Björn Gustavsson <[email protected]> | 2018-06-07 13:24:03 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2018-06-07 13:24:03 +0200 |
commit | 463c8e7fa08388f138fd9f07995d7c7a7580507e (patch) | |
tree | cb19a07659cf3034e3d902f455c5b2b7eae0d067 /lib/compiler/test/core_SUITE_data/name_capture.core | |
parent | 9ee83cf9c8d5b322e5361ebc067c00222c0c56ae (diff) | |
parent | 7eb06ed5ac1687d38245db2e0aef2756cb43b1ae (diff) | |
download | otp-463c8e7fa08388f138fd9f07995d7c7a7580507e.tar.gz otp-463c8e7fa08388f138fd9f07995d7c7a7580507e.tar.bz2 otp-463c8e7fa08388f138fd9f07995d7c7a7580507e.zip |
Merge pull request #1831 from bjorng/bjorn/compiler/fix-name-capture
Fix name capture problem in sys_core_fold
OTP-15115
Diffstat (limited to 'lib/compiler/test/core_SUITE_data/name_capture.core')
-rw-r--r-- | lib/compiler/test/core_SUITE_data/name_capture.core | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/lib/compiler/test/core_SUITE_data/name_capture.core b/lib/compiler/test/core_SUITE_data/name_capture.core new file mode 100644 index 0000000000..0969f95b72 --- /dev/null +++ b/lib/compiler/test/core_SUITE_data/name_capture.core @@ -0,0 +1,110 @@ +module 'name_capture' ['module_info'/0, + 'module_info'/1, + 'name_capture'/0] + attributes ['compile' = + [{'inline',[{'badarg_exit',2}]}]] +'name_capture'/0 = + fun () -> + case <> of + <> when 'true' -> + let <_0> = + catch + apply 'first'/1 + ('badarg') + in case _0 of + <{'EXIT',{'badarg',_7}}> when 'true' -> + let <Seq> = + call 'lists':'seq' + (7, 17) + in case apply 'first'/1 + ({'ok',Seq}) of + <_8> + when call 'erlang':'=:=' + (_8, + Seq) -> + let <SomeOtherTerm> = + {'some','other','term'} + in let <_5> = + catch + apply 'first'/1 + (SomeOtherTerm) + in case _5 of + <{'EXIT',_9}> + when call 'erlang':'=:=' + (_9, + SomeOtherTerm) -> + 'ok' + <_6> when 'true' -> + primop 'match_fail' + ({'badmatch',_6}) + end + <_3> when 'true' -> + primop 'match_fail' + ({'badmatch',_3}) + end + <_1> when 'true' -> + primop 'match_fail' + ({'badmatch',_1}) + end + <> when 'true' -> + primop 'match_fail' + ({'function_clause'}) + end +'first'/1 = + fun (_0) -> + case _0 of + <Tab> when 'true' -> + let <_1> = + apply 'treq'/2 + (Tab, 'first') + %% The _1 variable in the `let` must be renamed + %% to avoid a name capture problem. + in let <_0,_1> = + <_1,[Tab|[]]> + in case <_0,_1> of + <'badarg',A> when 'true' -> + call 'erlang':'error' + ('badarg', A) + <{'ok',Reply},_X_A> when 'true' -> + Reply + <Reply,_X_A> when 'true' -> + call 'erlang':'exit' + (Reply) + <_3,_2> when 'true' -> + primop 'match_fail' + ({'function_clause',_3,_2}) + end + <_2> when 'true' -> + primop 'match_fail' + ({'function_clause',_2}) + end +'treq'/2 = + fun (_0,_1) -> + case <_0,_1> of + <Action,_4> when 'true' -> + Action + <_3,_2> when 'true' -> + primop 'match_fail' + ({'function_clause',_3,_2}) + end +'module_info'/0 = + fun () -> + case <> of + <> when 'true' -> + call 'erlang':'get_module_info' + ('name_capture') + <> when 'true' -> + primop 'match_fail' + ({'function_clause'}) + end +'module_info'/1 = + fun (_0) -> + case _0 of + <X> when 'true' -> + call 'erlang':'get_module_info' + ('name_capture', X) + <_1> when 'true' -> + primop 'match_fail' + ({'function_clause',_1}) + end +end |