Skip to content

Commit fe45a12

Browse files
committed
Improves error reporting
For function headers with wrong typing this catched the error and recovers better, preventing further spurious (fake) errors.
1 parent cda14fe commit fe45a12

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/libzxbc/zxbparser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2911,6 +2911,13 @@ def p_function_header(p):
29112911
p[0] = p[1]
29122912

29132913

2914+
def p_function_header_error(p):
2915+
""" function_header : function_def error CO
2916+
| function_def error NEWLINE
2917+
"""
2918+
p[0] = None
2919+
2920+
29142921
def p_function_header_pre(p):
29152922
""" function_header_pre : function_def param_decl typedef
29162923
"""

tests/functional/test_errmsg.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ prepro76.bi:2: error: this is an intended error
176176
line_asm.bi:26: warning: this should be line 26
177177
>>> process_file('line_err.bas')
178178
line_err.bas:5: error: Variable 'q' already declared at line_err.bas:1
179+
>>> process_file('let_expr_type_crash.bas')
180+
let_expr_type_crash.bas:3: error: Syntax Error. Unexpected token 's' <ID>
181+
let_expr_type_crash.bas:8: error: Function 'editStringFN' takes 0 parameters, not 3
179182

180183
# Test warning silencing
181184
>>> process_file('mcleod3.bas', ['-S', '-q', '-O --expect-warnings=2'])
@@ -184,3 +187,4 @@ mcleod3.bas:3: error: 'GenerateSpaces' is neither an array nor a function.
184187
>>> process_file('doloop2.bas', ['-S', '-q', '-O -W110'])
185188
doloop2.bas:4: warning: [W100] Using default implicit type 'ubyte' for 'a'
186189
doloop2.bas:4: warning: [W150] Variable 'a' is never used
190+

0 commit comments

Comments
 (0)