Skip to content

Commit 3753cf5

Browse files
committed
fix: crash when using do loop with bad type
1 parent ef02b9e commit 3753cf5

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/api/check.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from src.api import config, errmsg, global_
1313
from src.api.constants import CLASS, SCOPE
1414
from src.symbols import sym as symbols
15+
from src.symbols.symbol_ import Symbol
1516
from src.symbols.type_ import Type
1617

1718
__all__ = [
@@ -318,7 +319,7 @@ def is_number(*p):
318319
"""Returns True if ALL the arguments are AST nodes
319320
containing NUMBER or numeric CONSTANTS
320321
"""
321-
return all(i.token in ("NUMBER", "CONST") and Type.is_numeric(i.type_) for i in p)
322+
return all(isinstance(i, Symbol) and i.token in ("NUMBER", "CONST") and Type.is_numeric(i.type_) for i in p)
322323

323324

324325
def is_static_str(*p):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DIM A AS UBYTE
2+
DO LOOP WHILE A = ""

tests/functional/cmdline/test_errmsg.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,8 @@ ND.Controls.bas:4: error: Invalid argument 'dirData'
159159
ND.Controls.bas:2: warning: [W150] Variable 'dirData' is never used
160160
>>> process_file('arch/zx48k/bad_fname_err4.bas', ['-S', '-q'])
161161
ND.Controls.bas:2: error: sub 'Controls_LABEL' declared but not implemented
162+
163+
# DO LOOP type errors
164+
>>> process_file('arch/zx48k/do_crash.bas', ['-S', '-q'])
165+
do_crash.bas:2: error: Cannot convert string to a value. Use VAL() function
166+
do_crash.bas:2: warning: [W130] Empty loop

0 commit comments

Comments
 (0)