+
+# Unwinding while unwinding
+{
+ package Scope::Upper::TestGuard;
+
+ sub new {
+ my $class = shift;
+ bless { cb => $_[0] }, $class;
+ }
+
+ sub DESTROY {
+ $_[0]->{cb}->()
+ }
+}
+
+{
+ my $desc = 'unwinding while unwinding';
+ local $@;
+
+ eval {
+ my @res = sub {
+ sub {
+ my $guard = Scope::Upper::TestGuard->new(sub {
+ my @res = sub {
+ sub {
+ unwind @_ => CALLER(1);
+ }->(@_);
+ fail "$desc (second): not reached";
+ }->(qw<a b c>);
+ is_deeply \@res, [ qw<a b c> ], "$desc (second): correct returned values";
+ });
+ unwind @_ => CALLER(1);
+ }->(@_);
+ fail "$desc (first): not reached";
+ }->(qw<y z>);
+ is_deeply \@res, [ qw<y z> ], "$desc (first): correct returned values";
+ };
+ is $@, '', "$desc: did not croak";
+}