-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Emit an error for the 'return' expression #1214
Conversation
My guess is that |
@jfecher A 'return' statement fails with an additional error when not followed by a semicolon, but I guess it's not an issue to allow that. |
@pczarn you should be able to remove the semicolon error by adding an appropriate case for Return in |
@jfecher Fixed according to your advice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 👍
Statement::Return { expr, semi: false } => { | ||
if !last_statement_in_block && semi.is_none() { | ||
let reason = "Expected a ; separating these two statements".to_string(); | ||
emit_error(ParserError::with_reason(reason, span)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of #1286, ParserError::with_reason
takes an enum (hence the failing tests). You can add a variant in parser/errors.rs
.
Closing as #1330 was merged |
Pull request was closed
Related issue(s)
Resolves #1190
Description
Emit the
Early 'return' is unsupported
message for the 'return' expressionDependency additions / changes
N/A
Test additions / changes
Added
return_validation
Checklist
cargo fmt
with default settings.Documentation needs
Additional context
N/A