Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/functional/substr_err.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
IF k$<>s$ THEN REM
IF m$(s(1),s(2))="\b" THEN LET m$(s(1),s(2))="\c"
9 changes: 8 additions & 1 deletion zxbparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,10 +1166,17 @@ def p_substr_assignment(p):
if entry.class_ == CLASS.unknown:
entry.class_ = CLASS.var

assert entry.class_ == CLASS.var and entry.type_ == TYPE.string
if entry.class_ != CLASS.var:
api.errmsg.syntax_error_cannot_assign_not_a_var(p.lineno(2), p[2])
return

if entry.type_ != TYPE.string:
api.errmsg.syntax_error_expected_string(p.lineno(2), entry.type_)
return

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

if len(p[3]) > 1:
syntax_error(p.lineno(2), "Accessing string with too many indexes. Expected only one.")
Expand Down