Permalink
Browse files

RT #81962, re-binding my &return

  • Loading branch information...
1 parent ab9c613 commit dec32f3ffbfefd17c25ef0c2008b664db632d8e6 @moritz moritz committed May 29, 2012
Showing with 16 additions and 1 deletion.
  1. +16 −1 S04-statements/return.t
@@ -1,6 +1,6 @@
use v6;
use Test;
-plan 15;
+plan 17;
# Is there a better reference for the spec for how return return works?
# There is "return function" but that's a more advanced feature.
@@ -53,4 +53,19 @@ is( try { sub foo { my $x = 1; while $x-- { return 24; }; return 42; }; foo() },
is($bar, '42 1', 'Should not return empty string');
}
+# RT #81962
+{
+ my $tracker = '';
+ my &r = &return;
+ sub f {
+ my &return := -> $v {
+ $tracker ~= 'LOL';
+ &r($v * 2);
+ };
+ return(21);
+ }
+ is f(), 42, 'proxied return produces the correct value';
+ is $tracker, 'LOL', 'proxied return produced the right side effect';
+}
+
# vim: ft=perl6

0 comments on commit dec32f3

Please sign in to comment.