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

For (1..10000000000) bug #923

Closed
p6rt opened this issue Apr 20, 2009 · 11 comments
Closed

For (1..10000000000) bug #923

p6rt opened this issue Apr 20, 2009 · 11 comments

Comments

@p6rt
Copy link

p6rt commented Apr 20, 2009

Migrated from rt.perl.org#64886 (status was 'resolved')

Searchable as RT64886$

@p6rt
Copy link
Author

p6rt commented Apr 20, 2009

From @teodozjan

$ cat normal.pl; ./perl6 normal.pl
for (1..5){
say "b";
}
b
b
b
b
b

$ cat destroyer.p6; ./perl6 destroyer.p6
say "start";
my $flag=0;

for (1..10000000000){
say "never executed";
}
say "end";
start
end

$ ./perl6 --version
This is Rakudo Perl 6, revision 38208 built on parrot 1.0.0-devel
for i486-linux-gnu-thread-multi.

Copyright 2006-2008, The Perl Foundation.

updated a while ago

--
Pozdrawiam

@p6rt
Copy link
Author

p6rt commented Apr 21, 2009

From @teodozjan

I've tried on another machine​:
$ ./perl6 -v
This is Rakudo Perl 6, revision 0 built on parrot 1.0.0-devel
for x86_64-linux-gnu-thread-multi.

Copyright 2006-2008, The Perl Foundation.

It eats whole cpu and starts eating memory.

--
Pozdrawiam

@p6rt
Copy link
Author

p6rt commented Apr 21, 2009

From @masak

On Tue Apr 21 13​:07​:28 2009, teodozjan@​gmail.com wrote​:

I've tried on another machine​:
$ ./perl6 -v
This is Rakudo Perl 6, revision 0 built on parrot 1.0.0-devel
for x86_64-linux-gnu-thread-multi.

Copyright 2006-2008, The Perl Foundation.

It eats whole cpu and starts eating memory.

Rakudo does somethings eagerly that will eventually be done lazily in
Perl 6. For-looping over ranges is one of those things.

@p6rt
Copy link
Author

p6rt commented Apr 21, 2009

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

@p6rt
Copy link
Author

p6rt commented Jul 27, 2010

From @bbkr

lists are now lazy and the given example works.

$ perl6 -e 'say "start"; my $flag=0; for (1..10000000000) { say "never
executed"; }; say "end";' | head
start
never executed
never executed
never executed
never executed
never executed
never executed
never executed
never executed
never executed

@p6rt
Copy link
Author

p6rt commented Jul 27, 2010

From @bbkr

and timings, proving that the list is lazy

real 0m1.499s
user 0m1.104s
sys 0m0.052s

@p6rt
Copy link
Author

p6rt commented Jul 30, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S04-statements/for.t

commit 651ee826e32816a994dd7c7ba3ff8da1f712ed36
Author​: bbkr <bbkr@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Fri Jul 30 17​:14​:28 2010 +0000

  [t/spec] tests for RT #​64886 For (1..10000000000) bug
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;31871 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S04-statements/for.t b/t/spec/S04-statements/for.t
index ea1acf0..d9858f4 100644
--- a/t/spec/S04-statements/for.t
+++ b/t/spec/S04-statements/for.t
@@ -478,6 +478,16 @@ eval 'for (my $x; $x <=3; $x++) { $i; }'; diag($!);
 ok $! ~~ / 'C-style' /, 'Sensible error message';
 }
 
+# RT #64886
+{
+    my $a = 0;
+    for (1..10000000000) {
+        $a++;
+        last;
+    }
+    is $a, 1, 'for on Range with huge max value is lazy and enters block';
+}
+
 done_testing;
 
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Jul 30, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S04-statements/for.t

commit 51b09b45c0597613232fd53586817afd83626cfc
Author​: bbkr <bbkr@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Fri Jul 30 17​:15​:14 2010 +0000

  [t/spec] tests for RT #​64886 For (1..10000000000) bug
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;31872 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S04-statements/for.t b/t/spec/S04-statements/for.t
index d9858f4..55d6c6e 100644
--- a/t/spec/S04-statements/for.t
+++ b/t/spec/S04-statements/for.t
@@ -242,7 +242,6 @@ my @elems = <a b c d e>;
 # .key //= ++$i for @array1;
 class TestClass{ has $.key is rw  };
 
-#?rakudo skip '[+] NYI'
 {
    my @array1 = (TestClass.new(:key<1>),TestClass.new());
    

@p6rt
Copy link
Author

p6rt commented Jul 30, 2010

From @bbkr

rechecked on * release, also works
tests in t/spec/S04-statements/for.t

@p6rt
Copy link
Author

p6rt commented Jul 30, 2010

@bbkr - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jul 30, 2010
@p6rt
Copy link
Author

p6rt commented Jul 30, 2010

From @bbkr

ignore 31872 commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant