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

Unexpected error...

0 views
Skip to first unread message

Cory Spencer

unread,
Dec 12, 2003, 4:00:52 PM12/12/03
to perl6-i...@perl.org

Can anyone tell me why the following code:

.sub _main
.local PerlUndef val

val = new PerlUndef
_foo("bar", val)

end
.end

.sub _foo
.param string v1
.param pmc v2

.pcc_begin_return
.return 1
.pcc_end_return
.end

Would produce the following output:

cog:~/parrot test.imc
wrong param count
in file '(unknown file)' near line -1

It seems to be related to passing the PerlUndef as the seoncd
parameter...

Melvin Smith

unread,
Dec 12, 2003, 4:57:58 PM12/12/03
to Cory Spencer, perl6-i...@perl.org

When using prototyped subs and mixing native types with PMC types as
arguments, IMCC will get confused. Its because it isn't correctly checking
the prototypes. The other problem is that when you use the shorthand
version of sub calling (_foo(a,b)), IMCC assumes prototyped.

It stems mainly from 2a below.

I recommend: (1) Using non_prototyped subs and explicit .pcc_call directives,
rather than the shorthand version for now.

Until I get some fixes committed you have a couple of other options:

(2) Don't mix PMCs and native types in argument lists if you use prototyped
subs
(2a) If you use PMCs, then IMCC won't coerce a constant argument into a
PMC yet. _foo("bar", val) will pass "bar" as a plain string type, even if
the prototype
expects a PMC. This is a bug.

I expect to have a large revision soon that will address lots of issues in
IMCC, but
it will most likely be in a new branch (imcc2) so as not to cause complete
chaos with
the "semi-stable" version. Then I will try to backpatch some of those fixes
into the
current IMCC.

-Melvin


0 new messages