Skip to content

Commit e60c04f

Browse files
committed
fix crash with VARPTR$ on undefined array elements
1 parent c96fdf0 commit e60c04f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

pcbasic/basic/memory/memory.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,10 @@ def varptr_(self, args):
515515
name = arg0
516516
error.throw_if(not name, error.STX)
517517
indices, = args
518+
name = self.complete_name(name)
519+
if indices != []:
520+
# pre-allocate array elements, but not scalars which instead throw IFC if undefined
521+
self.arrays.check_dim(name, indices)
518522
var_ptr = self.varptr(name, indices)
519523
return self.values.new_integer().from_int(var_ptr, unsigned=True)
520524

@@ -524,6 +528,7 @@ def varptr_str_(self, args):
524528
error.throw_if(not name, error.STX)
525529
indices = next(args)
526530
list(args)
531+
name = self.complete_name(name)
527532
if indices != []:
528533
# pre-allocate array elements, but not scalars which instead throw IFC if undefined
529534
self.arrays.check_dim(name, indices)

0 commit comments

Comments
 (0)