Skip to content
This repository

Bug in subroutine calling conventions #313

Closed
parrot opened this Issue · 5 comments

4 participants

Parrot Virtual Machine allisonrandal Will Coleda Andrew Whitworth
Parrot Virtual Machine
parrot commented

When running this code with the command 'parrot -':

.sub 'main' :main
    'aux'(5, 'hello', "b" => 3.14)
.end

.sub 'aux' 
    .param int a

    .param num b :named("b")

    .param string c :optional

    .param int has_c :opt_flag

    say a

    say b

    say c
.end

I get this error:

FixedIntegerArray: index out of bounds!

current instr.: 'aux' pc 16 (-:5)

called from Sub 'main' pc 11 (-:2)

Originally http://trac.parrot.org/parrot/ticket/792 by Axle

allisonrandal
Owner

The problem is that you put a named parameter ('b') in before the last positional parameter ('c'). Named parameters must follow all positional parameters in the declaration list.

But, agreed that the error message isn't at all helpful, that will need to be fixed.

Parrot Virtual Machine
parrot commented

Trac commenter: Axle

Replying to allison:

The problem is that you put a named parameter ('b') in before the last positional parameter ('c'). Named parameters must follow all positional parameters in the declaration list. But, agreed that the error message isn't at all helpful, that will need to be fixed.

Ah. Sorry this isn't a real bug. Thanks for the help.

Will Coleda
Owner
coke commented

This sample now generates the following output:

5
0


allison - is this new, non erroring behavior now correct? If so, we can add a test and close the ticket.

Andrew Whitworth
Owner

As far as I'm concerned (and second-opinions are welcome) this is correct behavior now and this ticket can be closed. I'll close it in a day or two, if nobody objects.

Andrew Whitworth
Owner

Yeah, I'm closing this. I don't see any part of this behavior as being unexpected or buggy. If we get a feature request to change it we can evaluate that separately, but for right now what we have is perfectly acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.