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
support non-numeric args to rhs of xx #1970
Comments
From @felliottHello, xx hangs if a non-numeric value appears on the right hand side: my @a = "b" xx "monkey"; my @c = <a b c> Attached is a patch which corrects this while still supporting a Whatever argument like so: my @f = <a b c> Z (1 xx *); # @f is <a 1 b 1 c 1> I've added fudged spectests to S03-operators/repeat.t and S05-transliteration/trans.t (this bug also causes .trans('x' => '') to hang). Cheers, |
From @felliott0001-force-xx-op-to-numify-rhs-except-Whatevers.patchFrom 60ff703ca544041436f77df5c6dd62add1167fe2 Mon Sep 17 00:00:00 2001
From: Fitz Elliott <felliott@virginia.edu>
Date: Sun, 25 Jul 2010 23:21:39 -0400
Subject: [PATCH] force xx op to numify rhs except Whatevers
---
src/core/operators.pm | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/core/operators.pm b/src/core/operators.pm
index 43a1fa8..74f8c23 100644
--- a/src/core/operators.pm
+++ b/src/core/operators.pm
@@ -267,10 +267,17 @@ our multi infix:<ge>($a, $b) {
}
# XXX Lazy version would be nice in the future too.
+class Whatever { ... }
+
+our multi infix:<xx>(Mu \$item, Whatever) {
+ (1..*).map( { $item } )
+}
+
our multi infix:<xx>(Mu \$item, $n) {
- (1..$n).map( { $item } )
+ (1..+$n).map( { $item } )
}
+
our multi prefix:<|>(@a) { @a.Capture }
our multi prefix:<|>(%h) { %h.Capture }
our multi prefix:<|>(Capture $c) { $c }
@@ -326,8 +333,6 @@ our multi sub item($item) {
$item
}
-class Whatever { ... }
-
our multi sub infix:<...>(Code $lhs, $rhs) {
my $limit;
$limit = $rhs if !($rhs ~~ Whatever);
--
1.7.2
|
From @cokeOn Sun Jul 25 21:33:01 2010, felliott wrote:
Looks like this patch was already applied, the samples here seem to work. However, I cannot -- |
The RT System itself - Status changed from 'new' to 'open' |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in at least one of these files: t/spec/S03-operators/repeat.t, t/spec/S05-transliteration/trans.t commit 18fcacf48d808b2d537a70a922bb6620fb4ecfe1 document RT # for spectests for RT #76720 Inline Patchdiff --git a/t/spec/S03-operators/repeat.t b/t/spec/S03-operators/repeat.t
index cddaef7..726fdfe 100644
--- a/t/spec/S03-operators/repeat.t
+++ b/t/spec/S03-operators/repeat.t
@@ -76,7 +76,7 @@ is($twin, 'LintillaLintilla', 'operator x= for string repeats correct');
}
-# tests for non-number values on rhs of xx
+# tests for non-number values on rhs of xx (RT #76720)
{
# make sure repeat numifies rhs, but respects whatever
my @a = <a b c>;
diff --git a/t/spec/S05-transliteration/trans.t b/t/spec/S05-transliteration/trans.t
index b282268..2f96de4 100644
--- a/t/spec/S05-transliteration/trans.t
+++ b/t/spec/S05-transliteration/trans.t
@@ -111,6 +111,7 @@ is($b.trans('A..H..' => 'a..h__'), 'abcdefghIJKLMNOPQRSTUVWXYZ',
is($b.trans('..A..H..' => '__a..h__'), 'abcdefghIJKLMNOPQRSTUVWXYZ',
'leading, trailing ranges interpreted as string');
+# added as a consequence of RT #76720
is("hello".trans("l" => ""), "heo", "can replace with empty string");
# complement, squeeze/squash, delete |
From @felliottThis should be fixed and the test has been properly marked up, so I am Cheers, |
@felliott - Status changed from 'open' to 'resolved' |
From @felliottOn Jul 27, 2010, at 9:56 PM, Will Coleda via RT wrote:
Sorry, I forgot to document the bug number in the test. I'll add it now. Cheers, |
Migrated from rt.perl.org#76720 (status was 'resolved')
Searchable as RT76720$
The text was updated successfully, but these errors were encountered: