Skip to content

Commit

Permalink
Fill array with nil values when assigning to an index > length
Browse files Browse the repository at this point in the history
Signed-off-by: Ted Reed <ted.reed@gmail.com>
  • Loading branch information
joeri authored and treed committed Aug 2, 2009
1 parent 550139a commit a61bd4b
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/classes/Array.pir
Expand Up @@ -1412,10 +1412,24 @@ Retrieve the number of elements in C<self>
.end

.sub '[]=' :method
.param pmc k
.param pmc i
.param pmc v
self[k] = v
.return()
.local int length
.local pmc nil

length = elements self
if i <= length goto set_value

nil = get_hll_global 'nil'
loop:
self[length] = nil

inc length
if i > length goto loop

set_value:
self[i] = v
.return (v)
.end

=item zip
Expand Down

0 comments on commit a61bd4b

Please sign in to comment.