Skip to content

Commit

Permalink
fix: parser would hand on function type with colon in it (#6764)
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite authored Dec 10, 2024
1 parent 0ba3e85 commit 9d7aadc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion compiler/noirc_frontend/src/parser/parser/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl<'a> Parser<'a> {
typ
} else {
self.expected_label(ParsingRuleLabel::Type);
self.unspecified_type_at_previous_token_end()
UnresolvedTypeData::Error.with_span(self.span_at_previous_token_end())
}
}

Expand Down Expand Up @@ -660,6 +660,14 @@ mod tests {
assert!(unconstrained);
}

#[test]
fn parses_function_type_with_colon_in_parameter() {
let src = "fn(value: T) -> Field";
let mut parser = Parser::for_str(src);
let _ = parser.parse_type_or_error();
assert!(!parser.errors.is_empty());
}

#[test]
fn parses_trait_as_type_no_generics() {
let src = "impl foo::Bar";
Expand Down

0 comments on commit 9d7aadc

Please sign in to comment.