Skip to content

Commit 9d7aadc

Browse files
authored
fix: parser would hand on function type with colon in it (#6764)
1 parent 0ba3e85 commit 9d7aadc

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • compiler/noirc_frontend/src/parser/parser

compiler/noirc_frontend/src/parser/parser/types.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl<'a> Parser<'a> {
1515
typ
1616
} else {
1717
self.expected_label(ParsingRuleLabel::Type);
18-
self.unspecified_type_at_previous_token_end()
18+
UnresolvedTypeData::Error.with_span(self.span_at_previous_token_end())
1919
}
2020
}
2121

@@ -660,6 +660,14 @@ mod tests {
660660
assert!(unconstrained);
661661
}
662662

663+
#[test]
664+
fn parses_function_type_with_colon_in_parameter() {
665+
let src = "fn(value: T) -> Field";
666+
let mut parser = Parser::for_str(src);
667+
let _ = parser.parse_type_or_error();
668+
assert!(!parser.errors.is_empty());
669+
}
670+
663671
#[test]
664672
fn parses_trait_as_type_no_generics() {
665673
let src = "impl foo::Bar";

0 commit comments

Comments
 (0)