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

feat: fault-tolerant parsing of fn and impl #5753

Merged
merged 12 commits into from
Aug 19, 2024
Prev Previous commit
Next Next commit
name -> type
  • Loading branch information
asterite committed Aug 18, 2024

Verified

This commit was signed with the committer’s verified signature.
mp911de Mark Paluch
commit 4bdb55b20350628f0939f09f0efcfcc50e9fb86d
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/parser/errors.rs
Original file line number Diff line number Diff line change
@@ -26,8 +26,8 @@ pub enum ParserErrorReason {
ExpectedLeftBraceAfterIfCondition,
#[error("expected <, where or {{ after trait name")]
ExpectedLeftBracketOrWhereOrLeftBraceOrArrowAfterTraitName,
#[error("expected <, where or {{ after impl name")]
ExpectedLeftBracketOrWhereOrLeftBraceOrArrowAfterImplName,
#[error("expected <, where or {{ after impl typw")]
ExpectedLeftBracketOrWhereOrLeftBraceOrArrowAfterImplType,
#[error("expected <, where or {{ after trait impl for type")]
ExpectedLeftBracketOrWhereOrLeftBraceOrArrowAfterTraitImplForType,
#[error("Expected a ; separating these two statements")]
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/parser/parser.rs
Original file line number Diff line number Diff line change
@@ -237,7 +237,7 @@ fn implementation() -> impl NoirParser<TopLevelStatement> {
methods
} else {
emit(ParserError::with_reason(
ParserErrorReason::ExpectedLeftBracketOrWhereOrLeftBraceOrArrowAfterImplName,
ParserErrorReason::ExpectedLeftBracketOrWhereOrLeftBraceOrArrowAfterImplType,
span,
));
vec![]
@@ -1781,7 +1781,7 @@ mod test {

let (top_level_statement, errors) = parse_recover(implementation(), src);
assert_eq!(errors.len(), 1);
assert_eq!(errors[0].message, "expected <, where or { after impl name");
assert_eq!(errors[0].message, "expected <, where or { after impl type");

let top_level_statement = top_level_statement.unwrap();
let TopLevelStatement::Impl(impl_) = top_level_statement else {