Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix infix:<x> accidentally silencing failures
An earlier fix[^1] to interpret type objects as 0 iterations had an unintended
effect that Failures from the coercion of the RHS argument to Int would also be
silently treaded as 0.

Add a separate multi for type objects to handle that case, leaving
coercion Failures able to freely explode.

Fixes RT#129899: https://rt.perl.org/Ticket/Display.html?id=129899
[1] 2311372
  • Loading branch information
zoffixznet committed Oct 16, 2016
1 parent ae1f2f8 commit 2dd0ddb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/Stringy.pm
Expand Up @@ -23,7 +23,8 @@ multi sub infix:<x>($s, Num:D $n) {
?? Failure.new(X::NYI.new(:feature('Cat object')))
!! $s.Stringy x $n.Int;
}
multi sub infix:<x>($s, $n) { $s.Stringy x ($n.Int // 0) }
multi sub infix:<x>($s, Any:D $n) { $s.Stringy x $n.Int }
multi sub infix:<x>($s, Any:U $n) { $s.Stringy x 0 }

proto sub infix:<leg>(Mu $?, Mu $?) is pure { * }
multi sub infix:<leg>(\a, \b) { a.Stringy cmp b.Stringy }
Expand Down

0 comments on commit 2dd0ddb

Please sign in to comment.