Skip to content
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(parser): return statements unsupported #1297

Closed
wants to merge 2 commits into from

Conversation

joss-aztec
Copy link
Contributor

Related issue(s)

Resolves #1190

Description

Summary of changes

Adds a parsing rule for return statements, such that users are shown a more informative error when they attempt to use it.

Dependency additions / changes

Test additions / changes

Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt with default settings.
  • I have linked this PR to the issue(s) that it resolves.
  • I have reviewed the changes on GitHub, line by line.
  • I have ensured all changes are covered in the description.

Documentation needs

  • This PR requires documentation updates when merged.

Additional context

@kevaundray
Copy link
Contributor

related to #1214

Comment on lines 473 to 477
.map(|_| Statement::Error)
.validate(|expr, span, emit| {
emit(ParserError::with_reason(ParserErrorReason::EarlyReturnUnsupported, span));
expr
})
Copy link
Contributor

@jfecher jfecher May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate also maps the input, so we can remove the map to return Statement::Error directly in validate:

Suggested change
.map(|_| Statement::Error)
.validate(|expr, span, emit| {
emit(ParserError::with_reason(ParserErrorReason::EarlyReturnUnsupported, span));
expr
})
.validate(|_, span, emit| {
emit(ParserError::with_reason(ParserErrorReason::EarlyReturnUnsupported, span));
Statement::Error
})

@jfecher
Copy link
Contributor

jfecher commented May 9, 2023

Closing in favor of #1214

@jfecher jfecher closed this May 9, 2023
@TomAFrench TomAFrench deleted the joss/parse-return-as-err branch November 20, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue an error when return is used
3 participants