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

[perl #41291] [BUG} Can't use null PMC with :multi sub

4 views
Skip to first unread message

Matt Diephouse

unread,
Jan 18, 2007, 3:58:50 PM1/18/07
to bugs-bi...@rt.perl.org
# New Ticket Created by Matt Diephouse
# Please include the string: [perl #41291]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41291 >


The example says it all.

--
Matt Diephouse


~/Projects/parrot mdiep$ cat test.pir
.sub main :main
null $P0
multi($P0) # should print "Any\n"
.end

.sub multi :multi(String)
say "String"
.end

.sub multi :multi(_)
say "Any"
.end

~/Projects/parrot mdiep$ parrot test.pir
Null PMC access in type()
current instr.: 'main' pc 10 (test.pir:4)
~/Projects/parrot mdiep$

Leopold Toetsch

unread,
Jan 18, 2007, 4:51:51 PM1/18/07
to perl6-i...@perl.org, Matt Diephouse, bugs-bi...@rt.perl.org
Am Donnerstag, 18. Januar 2007 21:58 schrieb Matt Diephouse:
>    ~/Projects/parrot mdiep$ cat test.pir
>    .sub main :main
>        null $P0
>        multi($P0) # should print "Any\n"
>    .end
>
>    .sub multi :multi(String)
>        say "String"
>    .end
>
>    .sub multi :multi(_)
>        say "Any"
>    .end
>
>    ~/Projects/parrot mdiep$ parrot test.pir
>    Null PMC access in type()

While that was never actually specced, I do consider a NULL PMC as something
like a null pointer in C. Any access (except testing for NULL-ness) to it is
an error. Above example tests, that some usage of a NULL PMC fails.

It's of course debatable, which usage of NULL should be allowed, e.g. above
one. An explicit test in PMC->type conversion for PMCNULL in the MMD code is
very likely all to make above code running (mmd.c:167,168).

my 2¢
leo

Christoph Otto via RT

unread,
Sep 17, 2008, 7:51:24 PM9/17/08
to perl6-i...@perl.org
On Thu Jan 18 14:14:30 2007, mdiep wrote:

> On Thu Jan 18 13:52:33 2007, leo wrote:
> > While that was never actually specced, I do consider a NULL PMC as
> > something
> > like a null pointer in C. Any access (except testing for NULL-ness)
> to
> > it is
> > an error. Above example tests, that some usage of a NULL PMC fails.
> >
> > It's of course debatable, which usage of NULL should be allowed,
> e.g.
> > above
> > one. An explicit test in PMC->type conversion for PMCNULL in the MMD
> > code is
> > very likely all to make above code running (mmd.c:167,168).
>
> I based the bug report on the behavior of normal subs:

>
> .sub main :main
> null $P0
> foo($P0) # this *does* print "foo\n"
> .end
> .sub foo
> say "foo"
> .end
>
> I don't know that I particularly need to be able to pass null PMCs to
> a MultiSub, but I at least
> demand a better error message. :-) I think either way will be trivial
> to write, but it probably
> needs some input from the architect.
>
> --
> Matt Diephouse
>

The above code prints "Any" in the mmd branch. Unless that's an
unwanted behavior, it looks like this ticket can be resolved once the
mmd branch is merged.

Will Coleda via RT

unread,
Oct 15, 2008, 3:12:49 PM10/15/08
to perl6-i...@perl.org
On Thu Jan 18 12:58:49 2007, mdiep wrote:
> The example says it all.
>
> --
> Matt Diephouse
>
>
> ~/Projects/parrot mdiep$ cat test.pir
> .sub main :main
> null $P0
> multi($P0) # should print "Any\n"
> .end
>
> .sub multi :multi(String)
> say "String"
> .end
>
> .sub multi :multi(_)
> say "Any"
> .end
>
> ~/Projects/parrot mdiep$ parrot test.pir
> Null PMC access in type()
> current instr.: 'main' pc 10 (test.pir:4)
> ~/Projects/parrot mdiep$

Added as a (passing) test in revision 31980.

Closing ticket.
--
Will "Coke" Coleda

0 new messages