Skip to content

Commit 619dbd6

Browse files
committed
Fix crash upon syntax error
1 parent a2d03a1 commit 619dbd6

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/libzxbc/zxbparser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,10 @@ def p_return_expr(p):
20742074
p[0] = None
20752075
return
20762076

2077+
if FUNCTION_LEVEL[-1].type_ is None: # There was an error in the Function declaration
2078+
p[0] = None
2079+
return
2080+
20772081
if is_numeric(p[2]) and FUNCTION_LEVEL[-1].type_ == TYPE.string:
20782082
error(p.lineno(2), 'Type Error: Function must return a string, not a numeric value')
20792083
p[0] = None

tests/functional/due_crash.bas

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function test(code as Ubyte) as Ubyte
2+
return 1
3+
end Function
4+

0 commit comments

Comments
 (0)