Skip Menu |
Report information
Id: 60482
Status: resolved
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: Rakudo dies strangely on .trans call in for loop on .split result
Date: Tue, 11 Nov 2008 17:42:37 +0100
To: rakudobug [...] perl.org
From: "Carl Mäsak" <cmasak [...] gmail.com>
Download (untitled) / with headers
text/plain 470b
<masak> ...but now I've found something. seriously! <masak> rakudo: say "foo\nbar\nbaz".trans([ /\s+/ => " " ]) <p6eval> rakudo 32543: OUTPUT[foo bar baz␤] <masak> all good, yes? <masak> now look: <masak> rakudo: for "foo\nbar\nbaz".split( /\n ** 2..*/ ) { say .trans([ /\s+/ => " " ]) } <p6eval> rakudo 32543: OUTPUT[too few arguments passed (2) - 3 params expected␤current instr.: '_block25' pc -342568903 ((unknown file):-1)␤] <masak> HAH! * masak files ticket
Download (untitled) / with headers
text/plain 675b
<pmichaud> oh, I see the issu <pmichaud> issue <jnthn> pmurias: We don't explicitly construct a capture right now. <pmichaud> the strings that come back from PGE aren't Perl6Str <jnthn> Ah. <pmichaud> so it's calling the .trans method in (Parrot) String instead of (Perl 6) Str <jnthn> The Parrot string has a trans method? * jnthn didn't know that <jnthn> Makes sense though. <pmichaud> METHOD trans(STRING *src, PMC *table) { <masak> pmichaud: is it easy to fix? <pmichaud> masak: not at the moment. <jnthn> Needs HLL. :-( <pmichaud> we need to get HLL type mapping in place. <masak> oh well. <pmichaud> and then PGE will have to become smart enough to do that mapping.
Subject: Re: [perl #60482] Rakudo dies strangely on .trans call in for loop on .split result
Date: Wed, 12 Nov 2008 10:07:21 -0600
To: perl6-compiler [...] perl.org
From: "Patrick R. Michaud" <pmichaud [...] pobox.com>
Download (untitled) / with headers
text/plain 745b
On Tue, Nov 11, 2008 at 08:43:09AM -0800, Carl Mäsak wrote: Show quoted text
> <masak> rakudo: for "foo\nbar\nbaz".split( /\n ** 2..*/ ) { say > .trans([ /\s+/ => " " ]) } > <p6eval> rakudo 32543: OUTPUT[too few arguments passed (2) - 3 params > expected␤current instr.: '_block25' pc -342568903 ((unknown > file):-1)␤] > <masak> HAH! > * masak files ticket
The problem is that the strings returned in PGE's Match objects are Parrot String PMCs, and so the .trans method for String PMCs (src/pmc/string.pmc:867) ends up being used instead of the .trans method defined by Rakudo. This will all likely be fixed when we have HLL mapping in place, and when PGE is updated to understand HLL mapping. Until then, I think we're a little stuck on this one. Pm
Download (untitled) / with headers
text/plain 720b
On Wed Nov 12 08:07:43 2008, pmichaud wrote: Show quoted text
> On Tue, Nov 11, 2008 at 08:43:09AM -0800, Carl Mäsak wrote:
> > <masak> rakudo: for "foo\nbar\nbaz".split( /\n ** 2..*/ ) { say > > .trans([ /\s+/ => " " ]) } > > <p6eval> rakudo 32543: OUTPUT[too few arguments passed (2) - 3 params > > expected␤current instr.: '_block25' pc -342568903 ((unknown > > file):-1)␤] > > <masak> HAH! > > * masak files ticket
> > The problem is that the strings returned in PGE's Match objects > are Parrot String PMCs, and so the .trans method for String PMCs > (src/pmc/string.pmc:867) ends up being used instead of the .trans > method defined by Rakudo.
Added to the test suite as pugs r22999, and to rakudo in r32626. Cheers, Moritz
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.4k
On Wed Nov 12 08:07:43 2008, pmichaud wrote: Show quoted text
> On Tue, Nov 11, 2008 at 08:43:09AM -0800, Carl Mäsak wrote:
> > <masak> rakudo: for "foo\nbar\nbaz".split( /\n ** 2..*/ ) { say > > .trans([ /\s+/ => " " ]) } > > <p6eval> rakudo 32543: OUTPUT[too few arguments passed (2) - 3 params > > expected␤current instr.: '_block25' pc -342568903 ((unknown > > file):-1)␤] > > <masak> HAH! > > * masak files ticket
> > The problem is that the strings returned in PGE's Match objects > are Parrot String PMCs, and so the .trans method for String PMCs > (src/pmc/string.pmc:867) ends up being used instead of the .trans > method defined by Rakudo. > > This will all likely be fixed when we have HLL mapping in place, > and when PGE is updated to understand HLL mapping. Until then, I > think we're a little stuck on this one.
As a start towards fixing this, I've added a String.Scalar method that will promote Parrot String PMCs into Rakudo Str objects whenever the String PMC is asked for its scalar value (e.g., upon assignment). So, while $/[0].trans(...) will still go to the wrong object, assigning $/[0] to a scalar and then performing .trans(...) will get closer to what you want. Again, a lot of this gets solved by HLL mapping -- but even once we have HLL mapping this can be a very useful backstop. We also now have the .PARROT method, which can be used to find out exactly what type of object Parrot thinks something is (as opposed to how Rakudo sees it). Pm
On Wed Nov 12 08:07:43 2008, pmichaud wrote: Show quoted text
> On Tue, Nov 11, 2008 at 08:43:09AM -0800, Carl Mäsak wrote:
> > <masak> rakudo: for "foo\nbar\nbaz".split( /\n ** 2..*/ ) { say > > .trans([ /\s+/ => " " ]) } > > <p6eval> rakudo 32543: OUTPUT[too few arguments passed (2) - 3 params > > expected␤current instr.: '_block25' pc -342568903 ((unknown > > file):-1)␤] > > <masak> HAH! > > * masak files ticket
> > The problem is that the strings returned in PGE's Match objects > are Parrot String PMCs, and so the .trans method for String PMCs > (src/pmc/string.pmc:867) ends up being used instead of the .trans > method defined by Rakudo. > > This will all likely be fixed when we have HLL mapping in place, > and when PGE is updated to understand HLL mapping. Until then, I > think we're a little stuck on this one. > > Pm
Related to this, I am planning to reimplement .trans to use alternation in a grammar instead of the current implementation (which fakes LTM at the expense of generating lots of Matches). That may wait for LTM in PGE.
Download (untitled) / with headers
text/plain 874b
On Thu Nov 13 13:05:10 2008, moritz wrote: Show quoted text
> On Wed Nov 12 08:07:43 2008, pmichaud wrote:
> > On Tue, Nov 11, 2008 at 08:43:09AM -0800, Carl Mäsak wrote:
> > > <masak> rakudo: for "foo\nbar\nbaz".split( /\n ** 2..*/ ) { say > > > .trans([ /\s+/ => " " ]) } > > > <p6eval> rakudo 32543: OUTPUT[too few arguments passed (2) - 3 params > > > expected␤current instr.: '_block25' pc -342568903 ((unknown > > > file):-1)␤] > > > <masak> HAH! > > > * masak files ticket
> > > > The problem is that the strings returned in PGE's Match objects > > are Parrot String PMCs, and so the .trans method for String PMCs > > (src/pmc/string.pmc:867) ends up being used instead of the .trans > > method defined by Rakudo.
> > Added to the test suite as pugs r22999, and to rakudo in r32626.
These tests (in t/spec/integration/real-strings.t) now all pass, so closing ticket... Moritz


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org