-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #15961 - ohno418:top-level-let-stmt, r=Veykril
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. --- Fixes #14963. While I'm not really sure if handling a particular case in a special manner is appropriate, it would be good to suppress the excessive number of annoying and unrelated errors.
- Loading branch information
Showing
5 changed files
with
84 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
crates/parser/test_data/parser/inline/err/0024_top_level_let.rast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
1 change: 1 addition & 0 deletions
1
crates/parser/test_data/parser/inline/err/0024_top_level_let.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let ref foo: fn() = 1 + 3; |