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

Rakudo dies strangely on .trans calls to strings coming from PGE #405

Closed
p6rt opened this issue Nov 11, 2008 · 9 comments
Closed

Rakudo dies strangely on .trans calls to strings coming from PGE #405

p6rt opened this issue Nov 11, 2008 · 9 comments

Comments

@p6rt
Copy link

p6rt commented Nov 11, 2008

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

Searchable as RT60482$

@p6rt
Copy link
Author

p6rt commented Nov 11, 2008

From @masak

<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

@p6rt
Copy link
Author

p6rt commented Nov 11, 2008

From @masak

<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.

@p6rt
Copy link
Author

p6rt commented Nov 11, 2008

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

@p6rt
Copy link
Author

p6rt commented Nov 12, 2008

From @pmichaud

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

@p6rt
Copy link
Author

p6rt commented Nov 13, 2008

From @moritz

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.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Nov 13, 2008

From @pmichaud

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.

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

@p6rt
Copy link
Author

p6rt commented Nov 19, 2008

From @cjfields

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.

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.

@p6rt
Copy link
Author

p6rt commented Jan 20, 2009

From @moritz

On Thu Nov 13 13​:05​:10 2008, moritz wrote​:

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

@p6rt
Copy link
Author

p6rt commented Jan 20, 2009

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

@p6rt p6rt closed this as completed Jan 20, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant