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

Multiple bug fixes (list branch) #1841

Closed
p6rt opened this issue Jun 16, 2010 · 6 comments
Closed

Multiple bug fixes (list branch) #1841

p6rt opened this issue Jun 16, 2010 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 16, 2010

Migrated from rt.perl.org#75810 (status was 'rejected')

Searchable as RT75810$

@p6rt
Copy link
Author

p6rt commented Jun 16, 2010

From justin.sahs@gmail.com

Apply to branch list, commit ddb39d064c6e334f4d08
Fixes these bugs​:

core/operators.pm​:
  #​75674​: [BUG] [TODO] Make 4 ... 0, 1, 2, 3, 4 (an infix​:<...> with a
list to the right) do the right thing in Rakudo
  #​75698​: [BUG] Double zero when infix​:<...> proceeds from -5 to ^5
  #​74990​: Series of letters doesn't stop at end point

builtins/control.pir
  #​62178​: [BUG] gather+while only takes last value tested

Results of make spectest​:
Failed Test Stat Wstat Total Fail List of
Failed


t/spec/S02-builtin_data_types/array_exten 21 1 19
t/spec/S03-junctions/misc.rakudo 1 256 ?? ?? ??
t/spec/S03-metaops/cross.rakudo 1 256 26 22 16-26
t/spec/S03-metaops/hyper.rakudo 1 256 ?? ?? ??
t/spec/S04-statements/gather.rakudo 14 1 10
t/spec/S05-metasyntax/angle-brackets.raku 76 2 35-36
t/spec/S06-other/main-usage.t 8 3 1-3
t/spec/S06-other/main.t 1 256 5 8 2-5
t/spec/S06-signature/introspection.rakudo 1 256 ?? ?? ??
t/spec/S06-signature/named-parameters.rak 98 2 67-68
t/spec/S09-typed-arrays/arrays.rakudo 1 256 ?? ?? ??
t/spec/S12-class/open.t 1 256 10 4 9-10
t/spec/S12-methods/calling_sets.t 31 4 5-6 22-23
t/spec/S12-methods/parallel-dispatch.raku 39 2 18-19
t/spec/S32-array/rotate.t 1 256 ?? ?? ??
t/spec/integration/99problems-31-to-40.t 1 256 67 46 45-67
(36 subtests UNEXPECTEDLY SUCCEEDED), 1511 subtests skipped.
Failed 16/454 test scripts. -88/31900 subtests failed.
Files=454, Tests=31900, 1657 wallclock secs (1409.09 cusr + 117.35 csys =
1526.44 CPU)
Failed 16/454 test programs. -88/31900 subtests failed.
make​: *** [spectest] Error 255

@p6rt
Copy link
Author

p6rt commented Jun 16, 2010

From justin.sahs@gmail.com

Might help if i actually attached a patch :-|

@p6rt
Copy link
Author

p6rt commented Jun 16, 2010

From justin.sahs@gmail.com

fixes.patch
diff --git a/src/builtins/control.pir b/src/builtins/control.pir
index 30ba345..4a17f9c 100644
--- a/src/builtins/control.pir
+++ b/src/builtins/control.pir
@@ -224,16 +224,23 @@ src/builtins/control.pir - control flow related functions
     ex['type'] = .CONTROL_TAKE
     ex['severity'] = .EXCEPT_NORMAL
     ex['message'] = 'take without gather'
-
     $I0 = elements values
     if $I0 == 0 goto nil
     if $I0 > 1 goto many
-    values = values[0]
+	$P0 = values[0]
+    values = clone $P0
     goto done
   nil:
     values = '&Nil'()
     goto done
   many:
+    $I1 = 0
+  many_loop:
+    $P0 = values[$I1]
+	$P1 = clone $P0
+    values[$I1] = $P1
+	$I1 = $I1 + 1
+	if $I1 < $I0 goto many_loop
     values = '&infix:<,>'(values :flat)
   done:
     setattribute ex, 'payload', values
diff --git a/src/core/operators.pm b/src/core/operators.pm
index 7e02233..960227f 100644
--- a/src/core/operators.pm
+++ b/src/core/operators.pm
@@ -306,14 +306,24 @@ our multi sub item($item) {
 
 class Whatever { ... }
 
-# the magic one that handles stuff like
-# 'a' ... 'z' and 'z' ... 'a'
-our multi sub infix:<...>($lhs, $rhs) {
+our multi sub infix:<scmp>($lhs, $rhs) {
+    $lhs cmp $rhs;
+}
+
+our multi sub infix:<scmp>(Str $lhs, Str $rhs) {
+    $lhs.chars <=> $rhs.chars || $lhs cmp $rhs;
+}
+
+our multi sub infix:<scmp>($lhs, @rhs) {
+    $lhs scmp @rhs[0];
+}
+
+our multi sub infix:<...>($lhs is copy, $rhs) {
     if $rhs ~~ Whatever {
         my $i = $lhs;
         return gather {
             loop {
-                my $j = $i++;
+                my $j = $i.succ;
                 take $j;
             }
         }
@@ -321,35 +331,28 @@ our multi sub infix:<...>($lhs, $rhs) {
 
     gather {
         take $lhs;
-        if ($lhs cmp $rhs) == 1 {
-            my $x = $lhs;
-            # since my $a = 'a'; $a-- gives
-            # "Decrement out of range" we can't easily
-            # decrement over our target, which is why the
-            # case of going backwards is slighly more complicated
-            # than going forward
-            while (--$x cmp $rhs) == 1 {
-                # need to make a fresh copy here because of RT #62178
-                my $y = $x;
-                take $y;
-            }
-            take $x if ($x cmp $rhs) == 0;
-        } elsif ($lhs cmp $rhs) == -1 {
-            my $x = $lhs;
-            while (++$x cmp $rhs) <= 0 {
-                my $y = $x;
-                take $y;
-            }
+
+        if $lhs scmp $rhs == 1 {
+            # here, we use '== 1' instead of '>= 0'
+            # because my $a = 'a'; $a-- gives
+            # "Decrement out of range"
+            take $lhs while --$lhs scmp $rhs == 1;
+            take $lhs if $lhs scmp $rhs == 0;
+        }
+        elsif $lhs scmp $rhs == -1 {
+            take $lhs while ++$lhs scmp $rhs <= 0;
         }
 
         if $rhs ~~ Iterable {
-            for @($rhs) {
-                take $_;
-            }
-        }
+            # the first element has already been taken
+            # should be:
+            # take $_ for $rhs[1..*]; but this doesn't work yet
+            take $_ for $rhs[{1..$_-1}];
+       }
     }
 }
 
+
 # our multi sub infix:<...>($lhs, Code $rhs) {
 #     if $rhs.count != 1 {
 #         die "Series operator currently cannot handle blocks with count != 1";
@@ -368,24 +371,6 @@ our multi sub infix:<...>($lhs, $rhs) {
 #         }
 #     }
 # }
-#
-# our multi sub infix:<...>(@lhs, Whatever) {
-#     given @lhs.elems {
-#         when 2 {
-#             @lhs[0] ... { $_ + (@lhs[1] - @lhs[0]) };
-#         }
-#         when 3 {
-#             if @lhs[1] - @lhs[0] == @lhs[2] - @lhs[1] {
-#                 @lhs[0] ... { $_ + (@lhs[1] - @lhs[0]) };
-#             } elsif @lhs[1] / @lhs[0] == @lhs[2] / @lhs[1] {
-#                 @lhs[0] ... { $_ * (@lhs[1] / @lhs[0]) };
-#             } else {
-#                 fail "Unable to figure out pattern of series";
-#             }
-#         }
-#         default { fail "Unable to figure out pattern of series"; }
-#     }
-# }
 
 our multi sub infix:<...>(Code $lhs, $rhs) {
     my $limit;
@@ -407,17 +392,17 @@ our multi sub infix:<...>(Code $lhs, $rhs) {
 our multi sub infix:<...>(@lhs is copy, $rhs) {
     my sub succ-or-pred($lhs, $rhs) {
         if $rhs ~~ Whatever || $lhs cmp $rhs != 1 {
-            -> $x { $x.succ };
+            *.succ;
         } else {
-            -> $x { $x.pred };
+            *.pred;
         }
     }
 
     my sub succ-or-pred2($lhs0, $lhs1, $rhs) {
         if $lhs1 cmp $lhs0 == 0 {
-            $next = { $_ };
+            { $_ };
         } else {
-            $next = succ-or-pred($lhs1, $rhs);
+            succ-or-pred($lhs1, $rhs);
         }
     }
 
@@ -487,6 +472,13 @@ our multi sub infix:<...>(@lhs is copy, $rhs) {
                 }
             }
         }
+
+        if $rhs ~~ Iterable {
+            # the first element has already been taken
+            # should be:
+            # take $_ for $rhs[1..*]; but this doesn't work yet
+            take $_ for $rhs[{1..$_-1}];
+       }
     }
 }
 

@p6rt
Copy link
Author

p6rt commented Jun 16, 2010

justin.sahs@gmail.com - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 20, 2011

From @coke

On Wed Jun 16 09​:05​:34 2010, ciphertext wrote​:

Apply to branch list, commit ddb39d064c6e334f4d08
Fixes these bugs​:

Sorry, this branch has been deleted.

If these fixes are still relevant, we'd love a patch against the latest (nom) branch. Thanks, sorry
for the delay in processing.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Sep 20, 2011

@coke - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Sep 20, 2011
@p6rt p6rt added the patch 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