Skip to content

[Bug]: Compiler raises exception when unexpected condition in DO...LOOP #841

@garrafonsoft

Description

@garrafonsoft

Contact Details

@garrafonsoft

Compiler version

v1.17.2

What happened?

When compiling this code:

DIM A AS UBYTE
DO LOOP WHILE A = ""

the compiler ends abruptly with the traceback shown below.

The compiler should show an apropriate compiling error or warning, but not raise an exception.

Error and Warning messages

$ ./zxbc.py loop_bug.bas 
loop_bug.bas:2: error: Cannot convert string to a value. Use VAL() function
Traceback (most recent call last):
  File "./zxbasic/./zxbc.py", line 12, in <module>
    sys.exit(zxbc.main())  # Exit
             ^^^^^^^^^^^
  File "./zxbasic/src/zxbc/zxbc.py", line 95, in main
    zxbparser.parser.parse(input_, lexer=zxblex.lexer, tracking=True, debug=(OPTIONS.debug_level > 1))
  File "./zxbasic/src/ply/yacc.py", line 429, in parse
    p.callable(pslice)
  File "./zxbasic/src/zxbc/zxbparser.py", line 1853, in p_do_loop_while
    if is_number(r):
       ^^^^^^^^^^^^
  File "./zxbasic/src/api/check.py", line 321, in is_number
    return all(i.token in ("NUMBER", "CONST") and Type.is_numeric(i.type_) for i in p)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "./zxbasic/src/api/check.py", line 321, in <genexpr>
    return all(i.token in ("NUMBER", "CONST") and Type.is_numeric(i.type_) for i in p)
               ^^^^^^^
AttributeError: 'NoneType' object has no attribute 'token'

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions