Improve error handling for top-level let statements

This commit addresses the issue of excessive and unrelated errors
generated by top-level `let` statements. Now, only a single error is
produced, indicating that `let` statements are invalid at the top level.
This commit is contained in:
Yutaro Ohno 2023-11-25 15:01:51 +09:00
parent c9d189d137
commit e076192dd8
5 changed files with 86 additions and 44 deletions

View file

@ -0,0 +1,30 @@
SOURCE_FILE
ERROR
LET_KW "let"
WHITESPACE " "
IDENT_PAT
REF_KW "ref"
WHITESPACE " "
NAME
IDENT "foo"
COLON ":"
WHITESPACE " "
FN_PTR_TYPE
FN_KW "fn"
PARAM_LIST
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
EQ "="
WHITESPACE " "
BIN_EXPR
LITERAL
INT_NUMBER "1"
WHITESPACE " "
PLUS "+"
WHITESPACE " "
LITERAL
INT_NUMBER "3"
SEMICOLON ";"
WHITESPACE "\n"
error 0: expected an item

View file

@ -0,0 +1 @@
let ref foo: fn() = 1 + 3;