Skip to content

Commit 7618d48

Browse files
committed
Merged in bugfix/array_error (pull request #174)
bugfix: fix crash on wrong array definition Approved-by: Jose Rodriguez <[email protected]>
2 parents 9a419fb + 4ff6138 commit 7618d48

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

tests/functional/array_err.bas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
dim test(10,1) as ubyte => {{0,0,0,0,0,0,0,0,0,0,0}}
3+

tests/functional/test_errmsg.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,6 @@ bad_sigil.bas:2: warning: Parameter 'y' is never used
136136
>>> process_file('params_implicit.bas')
137137
params_implicit.bas:2: warning: Using default implicit type 'float' for 'y'
138138
params_implicit.bas:2: warning: Parameter 'y' is never used
139+
>>> process_file('array_err.bas')
140+
array_err.bas:2: Mismatched vector size. Expected 11 elements, got 1.
139141

zxbparser.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -732,19 +732,20 @@ def p_arr_decl_initialized(p):
732732
def check_bound(boundlist, remaining):
733733
""" Checks if constant vector bounds matches the array one
734734
"""
735+
lineno = p.lineno(8)
735736
if not boundlist: # Returns on empty list
736737
if not isinstance(remaining, list):
737738
return True # It's OK :-)
738739

739-
syntax_error(p.lineno(9), 'Unexpected extra vector dimensions. It should be %i' % len(remaining))
740+
syntax_error(lineno, 'Unexpected extra vector dimensions. It should be %i' % len(remaining))
740741

741742
if not isinstance(remaining, list):
742-
syntax_error(p.lineno(9), 'Mismatched vector size. Missing %i extra dimension(s)' % len(boundlist))
743+
syntax_error(lineno, 'Mismatched vector size. Missing %i extra dimension(s)' % len(boundlist))
743744
return False
744745

745746
if len(remaining) != boundlist[0].count:
746-
syntax_error(p.lineno(9), 'Mismatched vector size. Expected %i elements, got %i.' % (boundlist[0].count,
747-
len(remaining)))
747+
syntax_error(lineno, 'Mismatched vector size. Expected %i elements, got %i.' % (boundlist[0].count,
748+
len(remaining)))
748749
return False # It's wrong. :-(
749750

750751
for row in remaining:

0 commit comments

Comments
 (0)