Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't defer to return() #2306

Open
p6rt opened this issue Dec 25, 2010 · 7 comments
Open

Can't defer to return() #2306

p6rt opened this issue Dec 25, 2010 · 7 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 25, 2010

Migrated from rt.perl.org#81278 (status was 'open')

Searchable as RT81278$

@p6rt
Copy link
Author

p6rt commented Dec 25, 2010

From @moritz

On Rakudo 2010.12​:

use v6;
sub f($x) {
  multi return($nv) {
  nextwith($nv /2);
  }

  return $x;
}
say f 6

I'd expect that to output 3\n, but instead I get

Null PMC access in clone()
  in 'return' at line 1
  in 'f' at line 7​:test.pl
  in main program body at line 9​:test.pl

which is sad, because it prevents me from using a "neat" and evil trick.

@p6rt
Copy link
Author

p6rt commented Jan 12, 2011

From @masak

moritz (>)​:

On Rakudo 2010.12​:

use v6;
sub f($x) {
multi return($nv) {
nextwith($nv /2);
}

return $x;

}
say f 6

I'd expect that to output 3\n, but instead I get

Null PMC access in clone()
in 'return' at line 1
in 'f' at line 7​:test.pl
in main program body at line 9​:test.pl

which is sad, because it prevents me from using a "neat" and evil
trick.

<masak> rakudo​: my &r := &return; sub f { my sub return($v) { say
"LOL!"; &r($v + 10) }; return 42 }; say f
<p6eval> rakudo 9b8bad​: OUTPUT«LOL!␤52␤»
<masak> wow! that *works*!
<masak> moritz_! :D
<masak> moritz_​: I have a workaround for one of your RT tickets.
* masak adds it to that ticket
<moritz_> masak​: I have too. I just name the new return differently :-)
<masak> now you don't have to :)

@p6rt
Copy link
Author

p6rt commented Jan 12, 2011

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 4, 2013

From @bbkr

On 2012.12​:

<bbkr__> r​: sub f($x) { multi return($nv) { nextwith($nv /2); }; return $x; }; say f 6
<p6eval> rakudo 70262f​: OUTPUT«===SORRY!===␤Method 'is_dispatcher' not found for
invocant of class 'Block'␤»

@p6rt
Copy link
Author

p6rt commented Jul 8, 2015

From @coke

On Fri Jan 04 04​:38​:30 2013, bbkr wrote​:

On 2012.12​:

<bbkr__> r​: sub f($x) { multi return($nv) { nextwith($nv /2); };
return $x; }; say f 6
<p6eval> rakudo 70262f​: OUTPUT«===SORRY!===␤Method 'is_dispatcher'
not found for
invocant of class 'Block'␤»

Pretty much unchanged​:

$ perl6 -e 'sub f($x) { multi return($nv) { nextwith($nv /2); }; return $x; }; say f 6'
===SORRY!===
Cannot find method 'is_dispatcher'
$ perl6 --version
This is perl6 version 2015.06-217-g3776723 built on MoarVM version 2015.06-48-g017d184
--
Will "Coke" Coleda

1 similar comment
@p6rt
Copy link
Author

p6rt commented Jul 8, 2015

From @coke

On Fri Jan 04 04​:38​:30 2013, bbkr wrote​:

On 2012.12​:

<bbkr__> r​: sub f($x) { multi return($nv) { nextwith($nv /2); };
return $x; }; say f 6
<p6eval> rakudo 70262f​: OUTPUT«===SORRY!===␤Method 'is_dispatcher'
not found for
invocant of class 'Block'␤»

Pretty much unchanged​:

$ perl6 -e 'sub f($x) { multi return($nv) { nextwith($nv /2); }; return $x; }; say f 6'
===SORRY!===
Cannot find method 'is_dispatcher'
$ perl6 --version
This is perl6 version 2015.06-217-g3776723 built on MoarVM version 2015.06-48-g017d184
--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Aug 25, 2016

From @coke

On Wed Jul 08 09​:55​:39 2015, coke wrote​:

On Fri Jan 04 04​:38​:30 2013, bbkr wrote​:

On 2012.12​:

<bbkr__> r​: sub f($x) { multi return($nv) { nextwith($nv /2); };
return $x; }; say f 6
<p6eval> rakudo 70262f​: OUTPUT«===SORRY!===␤Method 'is_dispatcher'
not found for
invocant of class 'Block'␤»

Pretty much unchanged​:

$ perl6 -e 'sub f($x) { multi return($nv) { nextwith($nv /2); };
return $x; }; say f 6'
===SORRY!===
Cannot find method 'is_dispatcher'
$ perl6 --version
This is perl6 version 2015.06-217-g3776723 built on MoarVM version
2015.06-48-g017d184

Updated behavior​:

$ perl6 -e 'sub f($x) { multi return($nv) { nextwith($nv /2); }; return $x; }; say f 6'
Attempt to return outside of any Routine
  in any call_with_args at gen/moar/m-Metamodel.nqp line 3906
  in sub return at -e line 1
  in sub f at -e line 1
  in block <unit> at -e line 1

--
Will "Coke" Coleda

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant