aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/test
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-08-11 15:35:29 +0200
committerBjörn Gustavsson <[email protected]>2016-08-11 15:43:46 +0200
commitd39cac954fc76a838763ac1ac03cb71bf8e5d68d (patch)
tree16b3b7464f794f1f8911773e92d49201a6f26ff2 /lib/compiler/test
parent4ab154e94aaaf6cb4e610595a31609559eb1732c (diff)
downloadotp-d39cac954fc76a838763ac1ac03cb71bf8e5d68d.tar.gz
otp-d39cac954fc76a838763ac1ac03cb71bf8e5d68d.tar.bz2
otp-d39cac954fc76a838763ac1ac03cb71bf8e5d68d.zip
[ERL-209] Fix ambiguous_catch_try_state inconsistency error
It is not safe to share code between 'catch' blocks.
Diffstat (limited to 'lib/compiler/test')
-rw-r--r--lib/compiler/test/beam_jump_SUITE.erl19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/compiler/test/beam_jump_SUITE.erl b/lib/compiler/test/beam_jump_SUITE.erl
index 0b13adaff2..088f63606c 100644
--- a/lib/compiler/test/beam_jump_SUITE.erl
+++ b/lib/compiler/test/beam_jump_SUITE.erl
@@ -21,7 +21,7 @@
-export([all/0,suite/0,groups/0,init_per_suite/1,end_per_suite/1,
init_per_group/2,end_per_group/2,
- undefined_label/1]).
+ undefined_label/1,ambiguous_catch_try_state/1]).
suite() ->
[{ct_hooks,[ts_install_cth]}].
@@ -32,7 +32,8 @@ all() ->
groups() ->
[{p,[parallel],
- [undefined_label
+ [undefined_label,
+ ambiguous_catch_try_state
]}].
init_per_suite(Config) ->
@@ -57,3 +58,17 @@ flights(0, [], []) when [], 0; 0.0, [], false ->
clark;
flights(_, Reproduction, introduction) when false, Reproduction ->
responsible.
+
+%% [ERL-209] beam_jump would share 'catch' blocks, causing an
+%% ambiguous_catch_try_state error in beam_validator.
+
+ambiguous_catch_try_state(_Config) ->
+ {{'EXIT',{{case_clause,song},_}},{'EXIT',{{case_clause,song},_}}} =
+ checks(42),
+ ok.
+
+river() -> song.
+
+checks(Wanted) ->
+ %% Must be one line to cause the unsafe optimization.
+ {catch case river() of sheet -> begin +Wanted, if "da" -> Wanted end end end, catch case river() of sheet -> begin + Wanted, if "da" -> Wanted end end end}.