Ticket #1733 (closed bug: fixed)
calling convention broken
Reported by: | fperrad | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | core | Version: | 2.6.0 |
Severity: | high | Keywords: | |
Cc: | Language: | ||
Patch status: | Platform: |
Description
The scheme of calling convention used by Lua is broken.
With Lua, all known parameters are optional, and extra parameters or vararg are collected by a final slurpy.
The following PIR code shows the problem :
.sub 'main' :main $P1 = box "p1" $P2 = box "p2" $P3 = box "p3" f($P1, $P2, $P3) # ok f($P1, $P2) # ok f($P1) # fails .end # f() has 2 known parameters .sub 'f' .param pmc p1 :optional .param int has_p1 :opt_flag .param pmc p2 :optional .param int has_p2 :opt_flag .param pmc extra :slurpy unless has_p1 goto L1 say p1 unless has_p2 goto L1 say p2 $P0 = iter extra L2: unless $P0 goto L1 $P1 = shift $P0 say $P1 goto L2 L1: .end
Here, the current output :
p1 p2 p3 p1 p2 FixedPMCArray: Cannot set array size to a negative number (-1) current instr.: 'f' pc 45 (prm.pir:8) called from Sub 'main' pc 40 (prm.pir:8)
Change History
Note: See
TracTickets for help on using
tickets.