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

(FIRST/LAST Phasers doesn't work in loop/while structures) #6191

Open
p6rt opened this issue Apr 14, 2017 · 1 comment
Open

(FIRST/LAST Phasers doesn't work in loop/while structures) #6191

p6rt opened this issue Apr 14, 2017 · 1 comment
Labels

Comments

@p6rt
Copy link

p6rt commented Apr 14, 2017

Migrated from rt.perl.org#131152 (status was 'new')

Searchable as RT131152$

@p6rt
Copy link
Author

p6rt commented Apr 14, 2017

From usikov@ziex.by

perl6 -v
This is Rakudo version 2017.01 built on MoarVM version 2017.01

sub f {
  my $i = 0;
  while True {
  FIRST { say "FIRST​: $i"};
  LAST { say "LAST​: $i"};
  last if ++$i > 100;
  }
}

doesn't compile​:
===SORRY!===
Cannot reference undeclared local 'LOOP_BLOCK_1'


without FIRST gives an error​:

sub f {
  my $i = 0;
  while True {
  # FIRST { say "FIRST​: $i"};
  LAST { say "LAST​: $i"};
  last if ++$i > 100;
  }
}

f();

LAST​: 0
No such method '!capture_phasers' for invocant of type 'Code'
  in block <unit> at t1.p6 line 16


in Promises compiles but gives random results​:

await do for 1..10 { start {
  my $i = 0;
  loop {
  FIRST { say "FIRST​: $i"};
  LAST { say "LAST​: $i"};
  last if ++$i > 100;
  }
} }

FIRST​: 0
FIRST​: 0
FIRST​: 2
FIRST​: 0
LAST​: 0
LAST​: 5
LAST​: 5
FIRST​: 0
FIRST​: 0
FIRST​: 64
LAST​: 103
LAST​: 103
LAST​: 103
FIRST​: 103
LAST​: 104
FIRST​: 2
FIRST​: 98
LAST​: 102
LAST​: 102
LAST​: 102


changing loop/while to for 1..* solves first two issues, but​:


using for 1..* instead of loop give more stable, but still sometimes incorrect results with promises​:

await do for 1..10 { start {
  my $i = 0;
  for 1..* {
  FIRST { say "FIRST​: $i"};
  LAST { say "LAST​: $i"};
  #say $i;
  last if ++$i > 100;
  }
} }

FIRST​: 0
FIRST​: 0
FIRST​: 77
FIRST​: 0
LAST​: 101
LAST​: 101
LAST​: 101
LAST​: 101
FIRST​: 0
FIRST​: 0
LAST​: 101
FIRST​: 0
LAST​: 101
FIRST​: 0
LAST​: 101
FIRST​: 0
LAST​: 101
FIRST​: 0
LAST​: 101
LAST​: 101

@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