Skip to content

Commit 01429c3

Browse files
committed
[js] Make nqp::atposnd return null when there is a missing element
1 parent 0b6fa59 commit 01429c3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/vm/js/nqp-runtime/reprs.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,9 @@ class MultiDimArray extends REPR {
17351735

17361736
$$atposnd(idx) {
17371737
if (STable.primType != 0) throw new NQPException('wrong type');
1738-
return this.storage[this.$$calculateIndex(idx)];
1738+
const value = this.storage[this.$$calculateIndex(idx)];
1739+
if (value === undefined) return Null;
1740+
return value;
17391741
}
17401742

17411743
$$bindposnd(idx, value) {

0 commit comments

Comments
 (0)