diff options
author | Björn Gustavsson <[email protected]> | 2018-08-08 13:24:58 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2018-08-08 13:24:58 +0200 |
commit | df93c4203eed0f6dd424c91f53c3eee698eb88c5 (patch) | |
tree | 4fe02046cb48fdb32569da5aa2e4021806fd979a /lib/compiler/test | |
parent | 83bf5bea4b872be40253a8f25c9aec3b79d6d66f (diff) | |
parent | 783172ca6d0453e115e038edbb46f892c0d35241 (diff) | |
download | otp-df93c4203eed0f6dd424c91f53c3eee698eb88c5.tar.gz otp-df93c4203eed0f6dd424c91f53c3eee698eb88c5.tar.bz2 otp-df93c4203eed0f6dd424c91f53c3eee698eb88c5.zip |
Merge branch 'maint'
* maint:
Eliminate double computation of next var
beam_validator: Fix false diagnostic for a receive nested in a try
Diffstat (limited to 'lib/compiler/test')
-rw-r--r-- | lib/compiler/test/receive_SUITE.erl | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/lib/compiler/test/receive_SUITE.erl b/lib/compiler/test/receive_SUITE.erl index 81ef0d33f2..37e737084a 100644 --- a/lib/compiler/test/receive_SUITE.erl +++ b/lib/compiler/test/receive_SUITE.erl @@ -25,7 +25,7 @@ init_per_group/2,end_per_group/2, init_per_testcase/2,end_per_testcase/2, export/1,recv/1,coverage/1,otp_7980/1,ref_opt/1, - wait/1]). + wait/1,recv_in_try/1]). -include_lib("common_test/include/ct.hrl"). @@ -44,7 +44,8 @@ all() -> groups() -> [{p,test_lib:parallel(), - [recv,coverage,otp_7980,ref_opt,export,wait]}]. + [recv,coverage,otp_7980,ref_opt,export,wait, + recv_in_try]}]. init_per_suite(Config) -> @@ -305,4 +306,48 @@ wait_1(r, _, _) -> wait_1(A, B, C) -> {A,B,C}. +recv_in_try(_Config) -> + self() ! {ok,fh}, {ok,fh} = recv_in_try(infinity, native), + self() ! {ok,ignored}, {ok,42} = recv_in_try(infinity, plain), + self() ! {error,ignored}, nok = recv_in_try(infinity, plain), + timeout = recv_in_try(1, plain), + ok. + +recv_in_try(Timeout, Format) -> + try + receive + {Status,History} -> + %% {test,is_tuple,{f,148},[{x,0}]}. + %% {test,test_arity,{f,148},[{x,0},2]}. + %% {get_tuple_element,{x,0},0,{y,1}}. %y1 is fragile. + %% + %% %% Here the fragility of y1 would be be progated to + %% %% the 'catch' below. Incorrect, since get_tuple_element + %% %% can't fail. + %% {get_tuple_element,{x,0},1,{x,2}}. + %% + %% remove_message. %y1 fragility cleared. + FH = case Format of + native -> + id(History); + plain -> + id(42) + end, + case Status of + ok -> + {ok,FH}; + error -> + nok + end + after Timeout -> + timeout + end + catch + %% The fragility of y1 incorrectly propagated to here. + %% beam_validator would complain. + throw:{error,Reason} -> + {nok,Reason} + end. + + id(I) -> I. |