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

Pointy while loop fails to pass arguments to block when lazy #5639

Open
p6rt opened this issue Sep 4, 2016 · 3 comments
Open

Pointy while loop fails to pass arguments to block when lazy #5639

p6rt opened this issue Sep 4, 2016 · 3 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 4, 2016

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

Searchable as RT129195$

@p6rt
Copy link
Author

p6rt commented Sep 4, 2016

From @skids

$ perl6 -e '(while 42 { 42.say })[0..1]'
42
42
$ perl6 -e '(while 42 -> $f { 42.say })[0..1]'
Too few positionals passed; expected 1 argument but got 0
  in code at -e line 1
  in block <unit> at -e line 1

...at least, I think it is laziness that triggers this, unless there's
a more syntactical explanation.

# If seems to work fine
$ perl6 -e '(if 42 -> $f { 42.say })[0]'
42
$ perl6 -e '(if 42 { 42.say })[0]'
42

...as does with.

@p6rt
Copy link
Author

p6rt commented Sep 4, 2016

From @timo

In Seq.pm we hit InfiniteLoopIter calling &!body(), if we have "while $foo" instead, we hit WhileLoopIter, which also calls &!body().

I'm not sure whether to put a flag into those iterators to run different code (one for no arguments, one for one argument), and I'm not sure what exact code to use to figure out what the amount of arguments is (&!body.count or .arity?).

Other than that, we might want to duplicate both iter classes because the check for arity would probably not yet be eliminated by spesh and it could maybe become expensive?

@p6rt
Copy link
Author

p6rt commented Sep 4, 2016

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

@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