Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[BUG] can not call methods with "self"

4 views
Skip to first unread message

Jens Rieks

unread,
Mar 11, 2004, 10:34:23 AM3/11/04
to perl6-i...@perl.org, Leopold Toetsch
Hi,

attached is a patch to t/pmc/object-meths.t that adds a test that is currently
failing because IMCC rejects code like self."blah"()

jens

object-meths.t.patch

Dan Sugalski

unread,
Mar 11, 2004, 10:41:12 AM3/11/04
to Jens Rieks, perl6-i...@perl.org, Leopold Toetsch

Before I go and apply this, could you sync and retry? I'm not seeing
any test failures here, so there might be a crossing in the CVS.
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

Jens Rieks

unread,
Mar 11, 2004, 11:07:04 AM3/11/04
to Dan Sugalski, perl6-i...@perl.org
Hi,

On Thursday 11 March 2004 16:41, Dan Sugalski wrote:
> At 4:34 PM +0100 3/11/04, Jens Rieks wrote:
> >Hi,
> >
> >attached is a patch to t/pmc/object-meths.t that adds a test that is
> > currently failing because IMCC rejects code like self."blah"()
>
> Before I go and apply this, could you sync and retry? I'm not seeing
> any test failures here, so there might be a crossing in the CVS.

Its neither working on my computer nor on blao (tinderbox)...

t/pmc/object-meths....ok 7/8# Failed test (t/pmc/object-meths.t at line
185)
# got: 'error:imcc:parse error, unexpected '.', expecting '='
#
# in file 't/pmc/object-meths_8.imc' line 32
# '
# expected: 'A::foo
# A::blah
# B::blah
# A::blah
# B::foo
# '
# './parrot t/pmc/object-meths_8.imc' failed with exit code 1
# Looks like you failed 1 tests of 8.

jens

Leopold Toetsch

unread,
Mar 11, 2004, 11:33:24 AM3/11/04
to Jens Rieks, perl6-i...@perl.org
Jens Rieks <par...@jensbeimsurfen.de> wrote:

> attached is a patch to t/pmc/object-meths.t that adds a test that is
> currently failing because IMCC rejects code like self."blah"()

Yep. It produces reduce/reduce conflicts. Something's wrong with
precedence. I'd be glad if someone can fix it.

One more bug was in the code: P2 wasn't preserved around method calls.
Fixed too.

> jens

Thanks for the test,
leo

Dan Sugalski

unread,
Mar 11, 2004, 11:15:13 AM3/11/04
to Jens Rieks, perl6-i...@perl.org
At 5:07 PM +0100 3/11/04, Jens Rieks wrote:
>Hi,
>
>On Thursday 11 March 2004 16:41, Dan Sugalski wrote:
>> At 4:34 PM +0100 3/11/04, Jens Rieks wrote:
>> >Hi,
>> >
>> >attached is a patch to t/pmc/object-meths.t that adds a test that is
>> > currently failing because IMCC rejects code like self."blah"()
>>
>> Before I go and apply this, could you sync and retry? I'm not seeing
>> any test failures here, so there might be a crossing in the CVS.
>Its neither working on my computer nor on blao (tinderbox)...

Gotcha. Test applied, then, and we'll see where we go from here.

Steve Fink

unread,
Mar 12, 2004, 3:34:09 AM3/12/04
to Leopold Toetsch, perl6-i...@perl.org
On Mar-11, Leopold Toetsch wrote:
> Jens Rieks <par...@jensbeimsurfen.de> wrote:
>
> > attached is a patch to t/pmc/object-meths.t that adds a test that is
> > currently failing because IMCC rejects code like self."blah"()
>
> Yep. It produces reduce/reduce conflicts. Something's wrong with
> precedence. I'd be glad if someone can fix it.

The attached patch should remove all of the conflicts, and replace
them with a single shift/reduce conflict that appears to be a bug in
the actual grammar, namely:

x = x . x

can be parsed as

x = x . x
VAR '=' VAR '.' VAR
target '=' var '.' var
assignment

or

x = x . x
VAR '=' VAR '.' VAR
target '=' target ptr target
target '=' the_sub
target '=' sub_call
assignment

Personally, I'd probably also rename 'target' to 'lhs', and 'var' (and
its variants) to 'rhs'. But maybe that's just me. Oh, and 'lhs' is
available because this patch eliminates it.

I didn't try the test mentioned, though.

conflicts.patch

Leopold Toetsch

unread,
Mar 12, 2004, 2:44:14 PM3/12/04
to Steve Fink, perl6-i...@perl.org
Steve Fink <st...@fink.com> wrote:
> The attached patch should remove all of the conflicts, and replace
> them with a single shift/reduce conflict that appears to be a bug in
> the actual grammar, namely:

> x = x . x

Ah yes. Or course, Thanks a lot, applied.

leo

Steve Fink

unread,
Mar 13, 2004, 3:02:06 PM3/13/04
to Leopold Toetsch, perl6-i...@perl.org

But how should the two interpretations of x.x be resolved? Is that
concatenation or method calling?

Luka Frelih

unread,
Mar 13, 2004, 5:07:19 PM3/13/04
to perl6-i...@perl.org
> But how should the two interpretations of x.x be resolved? Is that
> concatenation or method calling?

currently, the pir line
S5 = S5 . 'foo'
produces
error:imcc:object isn't a PMC

concatenation with . seems to be gone
i cannot think of a good replacement for it

wouldnt it be better to keep . as string glue
and have method calls use the arrow -> or some
such?

also is there a good reason that .= is missing from imcc?

LF

Luke Palmer

unread,
Mar 13, 2004, 5:08:47 PM3/13/04
to luka frelih, perl6-i...@perl.org
luka frelih writes:
> >But how should the two interpretations of x.x be resolved? Is that
> >concatenation or method calling?
>
> currently, the pir line
> S5 = S5 . 'foo'
> produces
> error:imcc:object isn't a PMC
>
> concatenation with . seems to be gone
> i cannot think of a good replacement for it

Well, Perl 6 uses ~ . I think that would be a fair replacement:

S5 = S5 ~ 'foo'

Luke

Steve Fink

unread,
Mar 13, 2004, 5:42:53 PM3/13/04
to Luke Palmer, luka frelih, perl6-i...@perl.org

That currently means binary xor in imcc, so if we changed it we'd
break compatibility with current compilers and scripts.

OTOH, it sounds like I already broke it by changing the outcome of the
ambiguous x.x interpretation -- oops. I can change it back with
precedence games, but would rather not exert the effort, since I think
using ~ is a better way to go. (Barring other better ideas, that is.)
I tend to use the 'concat' op in my own code anyway. So I'll abide by
Leo's or Melvin's ruling.

Kenneth A Graves

unread,
Mar 13, 2004, 5:43:30 PM3/13/04
to perl6-i...@perl.org
On Sat, 2004-03-13 at 17:07, luka frelih wrote:
> > But how should the two interpretations of x.x be resolved? Is that
> > concatenation or method calling?
>
> wouldnt it be better to keep . as string glue
> and have method calls use the arrow -> or some
> such?

Or follow perl6 and use ~ for string concatenation. (Currently being
used for xor, which could use ^.)

--kag


Melvin Smith

unread,
Mar 13, 2004, 11:22:01 PM3/13/04
to Steve Fink, Luke Palmer, luka frelih, perl6-i...@perl.org
At 02:42 PM 3/13/2004 -0800, Steve Fink wrote:
> > > currently, the pir line
> > > S5 = S5 . 'foo'
> > > produces
> > > error:imcc:object isn't a PMC
> > >
> > > concatenation with . seems to be gone
> > > i cannot think of a good replacement for it
> >

This should be fixable with some lexer or parser tweaking.

>Well, Perl 6 uses ~ . I think that would be a fair replacement:
> >
> > S5 = S5 ~ 'foo'

We don't have the same ambiguity problems in PIR that we do
in Perl6 since PIR is very simple and uniform.

foo.baz is a method or member access
foo . baz is concatenation

For an intermediate language for multiple front end compilers
1) Strict rules are just fine
2) Eventually compilers will simply use the AST API and skip the
textual mode.

>I tend to use the 'concat' op in my own code anyway. So I'll abide by
>Leo's or Melvin's ruling.

Explicit concat works for me too.

Parsing PIR is not too complex, so I'm not worried about a lexer
kludge here or there. I prefer to keep the . for concat.

-Melvin

Leopold Toetsch

unread,
Mar 14, 2004, 2:59:38 AM3/14/04
to Melvin Smith, perl6-i...@perl.org
Melvin Smith <mrjol...@mindspring.com> wrote:

> foo.baz is a method or member access
> foo . baz is concatenation

So it is now. CONCAT requires whitespace on either side.

> -Melvin

leo

0 new messages