Skip to content

Commit 158002c

Browse files
committed
Merged in bugfix/parser_crash (pull request #217)
Bugfix/parser crash Approved-by: Jose Rodriguez <[email protected]>
2 parents 90aa502 + 404483c commit 158002c

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

tests/functional/callable_err.bas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
IF m$(s(1)-vm,s(2)-hm)="\c" THEN REM
2+
3+

tests/functional/substr_err.bas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
IF k$<>s$ THEN REM
2+
IF m$(s(1),s(2))="\b" THEN LET m$(s(1),s(2))="\c"

zxbparser.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,10 +1166,17 @@ def p_substr_assignment(p):
11661166
if entry.class_ == CLASS.unknown:
11671167
entry.class_ = CLASS.var
11681168

1169-
assert entry.class_ == CLASS.var and entry.type_ == TYPE.string
1169+
if entry.class_ != CLASS.var:
1170+
api.errmsg.syntax_error_cannot_assign_not_a_var(p.lineno(2), p[2])
1171+
return
1172+
1173+
if entry.type_ != TYPE.string:
1174+
api.errmsg.syntax_error_expected_string(p.lineno(2), entry.type_)
1175+
return
11701176

11711177
if p[5].type_ != TYPE.string:
11721178
api.errmsg.syntax_error_expected_string(p.lineno(4), p[5].type_)
1179+
return
11731180

11741181
if len(p[3]) > 1:
11751182
syntax_error(p.lineno(2), "Accessing string with too many indexes. Expected only one.")
@@ -2583,6 +2590,10 @@ def p_expr_funccall(p):
25832590
def p_idcall_expr(p):
25842591
""" func_call : ID arg_list %prec UMINUS
25852592
""" # This can be a function call or a string index
2593+
if p[2] is None:
2594+
p[0] = None
2595+
return
2596+
25862597
p[0] = make_call(p[1], p.lineno(1), p[2])
25872598
if p[0] is None:
25882599
return

0 commit comments

Comments
 (0)