Skip to content

Commit b4e4cfd

Browse files
committed
[truffle] Allow extanding array by assiging past their end
1 parent 9cfc927 commit b4e4cfd

File tree

1 file changed

+9
-1
lines changed
  • src/vm/jvm/runtime/org/perl6/nqp/truffle/runtime

1 file changed

+9
-1
lines changed

src/vm/jvm/runtime/org/perl6/nqp/truffle/runtime/NQPList.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ public Object atpos(long pos) {
2727
}
2828

2929
public Object bindpos(long pos, Object value) {
30-
return contents.set((int)pos, value);
30+
if (pos >= contents.size()) {
31+
for (int i = contents.size(); i < pos; i++) {
32+
contents.add(NQPNull.SINGLETON);
33+
}
34+
contents.add(value);
35+
return value;
36+
} else {
37+
return contents.set((int)pos, value);
38+
}
3139
}
3240

3341
public int elems() {

0 commit comments

Comments
 (0)