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

rindex fails on non-string invocant #300

Closed
p6rt opened this issue Sep 7, 2008 · 7 comments
Closed

rindex fails on non-string invocant #300

p6rt opened this issue Sep 7, 2008 · 7 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 7, 2008

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

Searchable as RT58644$

@p6rt
Copy link
Author

p6rt commented Sep 7, 2008

From @pmichaud

The rindex method added in r30858 has a bug​:

$ ./parrot perl6.pbc

say 85224.rindex('2');
Method 'reverse_index' not found for invocant of class 'Int'

Pm

@p6rt
Copy link
Author

p6rt commented Sep 7, 2008

From @moritz

Patrick R. Michaud (via RT) wrote​:

# New Ticket Created by Patrick R. Michaud
# Please include the string​: [perl #​58644]
# in the subject line of all future correspondence about this issue.
# <URL​: http://rt.perl.org/rt3/Ticket/Display.html?id=58644 >

The rindex method added in r30858 has a bug​:

$ ./parrot perl6.pbc

say 85224.rindex('2');
Method 'reverse_index' not found for invocant of class 'Int'

Added a (skipped) test to t/spec/S29-str/rindex.t

Moritz

--
Moritz Lenz
http://moritz.faui2k3.org/ | http://perl-6.de/

@p6rt
Copy link
Author

p6rt commented Sep 7, 2008

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

@p6rt
Copy link
Author

p6rt commented Sep 8, 2008

From @bacek

On Sun Sep 07 09​:32​:01 2008, pmichaud wrote​:

The rindex method added in r30858 has a bug​:

$ ./parrot perl6.pbc

say 85224.rindex('2');
Method 'reverse_index' not found for invocant of class 'Int'

Hello.

There is a patch for casting non-Strings to String. But I'm not quite
sure, that it is correct way...

--
Bacek

@p6rt
Copy link
Author

p6rt commented Sep 8, 2008

From @bacek

rindex.patch
diff --git a/languages/perl6/src/builtins/any-str.pir b/languages/perl6/src/builtins/any-str.pir
index f5c4bf2..3e2a387 100644
--- a/languages/perl6/src/builtins/any-str.pir
+++ b/languages/perl6/src/builtins/any-str.pir
@@ -106,7 +106,16 @@ the size of that file down and to emphasize their generic,
     goto done
 
   substring_search:
-    pos = self.'reverse_index'(substring, pos)
+    $I0 = self.'isa'('String')
+    if $I0 goto self_string
+    $P0 = new 'String'
+    $S0 = self
+    $P0 = $S0
+    goto do_search
+  self_string:
+    $P0 = self
+  do_search:
+    pos = $P0.'reverse_index'(substring, pos)
     if pos < 0 goto fail
 
   done:

@p6rt
Copy link
Author

p6rt commented Sep 10, 2008

From @moritz

On Sun Sep 07 21​:40​:06 2008, bacek wrote​:

On Sun Sep 07 09​:32​:01 2008, pmichaud wrote​:

The rindex method added in r30858 has a bug​:

$ ./parrot perl6.pbc

say 85224.rindex('2');
Method 'reverse_index' not found for invocant of class 'Int'

Hello.

There is a patch for casting non-Strings to String. But I'm not quite
sure, that it is correct way...

Well, we need a cast somehow, I don't see why it should be wrong
(though my PIR fu is limited).

Applied as r30947, thank you.

@p6rt
Copy link
Author

p6rt commented Sep 10, 2008

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

@p6rt p6rt closed this as completed Sep 10, 2008
@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