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

.trans is too strict in what arguments it rejects in Rakudo #2358

Closed
p6rt opened this issue Feb 8, 2011 · 7 comments
Closed

.trans is too strict in what arguments it rejects in Rakudo #2358

p6rt opened this issue Feb 8, 2011 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Feb 8, 2011

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

Searchable as RT83674$

@p6rt
Copy link
Author

p6rt commented Feb 8, 2011

From @masak

<masak> rakudo​: my @​a = 1..10; say ~(@​a>>.trans((1..26) => (14..26,1..13)))
<p6eval> rakudo a37640​: OUTPUT«No candidates found to invoke for
method 'increment_index' on object of type 'LSM'; available candidates
have signatures​:␤​:(Mu : Regex $s;; *%_)␤​:(Mu : Str $s;; *%_)␤␤ in
'Cool​::next_substitution' at line 2466​:CORE.setting␤ in 'Cool​::trans'
at line 2512​:CORE.setting␤ in main pro…
* masak submits rakudobug
<masak> that one's my fault. sorry 'bout that.
<masak> signature should probably be Cool, not Str.

For once, the whole error message is shock-full of pertinent details.
Thanks to it, I know exactly what the problem is, where it is, and how
to fix it.

@p6rt
Copy link
Author

p6rt commented Feb 8, 2011

From @masak

masak (>)​:

<masak> rakudo​: my @​a = 1..10; say ~(@​a>>.trans((1..26) => (14..26,1..13)))
<p6eval> rakudo a37640​: OUTPUT«No candidates found to invoke for
method 'increment_index' on object of type 'LSM'; available candidates
have signatures​:␤​:(Mu : Regex $s;; *%_)␤​:(Mu : Str $s;; *%_)␤␤  in
'Cool​::next_substitution' at line 2466​:CORE.setting␤  in 'Cool​::trans'
at line 2512​:CORE.setting␤  in main pro…
* masak submits rakudobug
<masak> that one's my fault. sorry 'bout that.
<masak> signature should probably be Cool, not Str.

For once, the whole error message is shock-full of pertinent details.
Thanks to it, I know exactly what the problem is, where it is, and how
to fix it.

Hm, the obvious fix is the following​:

Inline Patch
diff --git a/src/core/Cool-str.pm b/src/core/Cool-str.pm
index b35b779..ea3601a 100644
--- a/src/core/Cool-str.pm
+++ b/src/core/Cool-str.pm
@@ -212,7 +212,7 @@ augment class Cool {
             $!index = $!next_match + $/.chars;
         }

-        multi submethod increment_index(Str $s) {
+        multi submethod increment_index(Cool $s) {
             $!index = $!next_match + $s.chars;
         }

With it applied, I get the following (only partly satisfactory) output:

$ ./perl6 -e 'my @​a = 1..10; say "!$_!" for (@​a>>.trans((1..26) =>
(14..26,1..13)))'
!14!
!!
!!
!!
!!
!!
!!
!!
!!
!!

That is, the first transliteration call works as expected, but the
subsequent 9 don't. Maybe there's some state within the LTM engine
that isn't reset properly?

Will investigate more later.

// Carl

@p6rt
Copy link
Author

p6rt commented Feb 9, 2011

From @masak

Oh well. The original problem has been fixed. I'll open a new ticket for
the emergent problem.

This ticket just need tests and then it can be closed.

@p6rt
Copy link
Author

p6rt commented Feb 9, 2011

@masak - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Feb 23, 2011

From @zhuomingliang

test added. see Raku/roast@ff620eb9c8

@p6rt
Copy link
Author

p6rt commented Mar 12, 2011

From @kyleha

There's a test in S05-transliteration/trans.t, and it passes.

@p6rt
Copy link
Author

p6rt commented Mar 12, 2011

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

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

No branches or pull requests

1 participant