Skip to content

Commit d6e495b

Browse files
authored
Merge pull request #413 from boriel/feature/improve_error_reporting_for_arrays_assignment
Improve error message for LET array = <expr>
2 parents 31c5dfb + b41eceb commit d6e495b

5 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/libzxbc/zxbparser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,6 +2676,13 @@ def p_idcall_expr(p):
26762676
p[0].entry.accessed = True
26772677

26782678

2679+
def p_array_eq_error(p):
2680+
""" statement : LET ARRAY_ID EQ expr
2681+
"""
2682+
error(p.lineno(4), f"Invalid assignment. Variable {p[2]}() is an array")
2683+
p[0] = None
2684+
2685+
26792686
def p_arr_access_expr(p):
26802687
""" func_call : ARRAY_ID arg_list
26812688
""" # This is an array access

src/parsetab/tabs.dbm.bak

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'asmparse', (0, 254316)
2-
'zxnext_asmparse', (254464, 285309)
3-
'zxbppparse', (540160, 69623)
4-
'zxbparser', (609792, 710716)
1+
'asmparse', (0, 254311)
2+
'zxnext_asmparse', (254464, 285299)
3+
'zxbparser', (540160, 712099)

src/parsetab/tabs.dbm.dat

-66.6 KB
Binary file not shown.

src/parsetab/tabs.dbm.dir

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'asmparse', (0, 254316)
2-
'zxnext_asmparse', (254464, 285309)
3-
'zxbppparse', (540160, 69623)
4-
'zxbparser', (609792, 710716)
1+
'asmparse', (0, 254311)
2+
'zxnext_asmparse', (254464, 285299)
3+
'zxbparser', (540160, 712099)

tests/functional/test_errmsg.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,6 @@ due_par.bas:2: error: Syntax error. Unexpected end of line
168168
>>> process_file('due_inc_main.bas')
169169
due_par.bas:2: error: Syntax error. Unexpected end of line
170170
due_par.bas:5: error: Syntax error. Unexpected end of file
171+
>>> process_file('error_array.bas')
172+
error_array.bas:3: error: Invalid assignment. Variable z$() is an array
173+

0 commit comments

Comments
 (0)