From a5b27747b67f8bdf6e8ebc73b7121693b846582d Mon Sep 17 00:00:00 2001 From: Ary Borenszweig Date: Tue, 10 Dec 2024 16:11:49 -0300 Subject: [PATCH] fix: parser would hand on function type with colon in it --- compiler/noirc_frontend/src/parser/parser/types.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/noirc_frontend/src/parser/parser/types.rs b/compiler/noirc_frontend/src/parser/parser/types.rs index 0de94a89be5..884db763698 100644 --- a/compiler/noirc_frontend/src/parser/parser/types.rs +++ b/compiler/noirc_frontend/src/parser/parser/types.rs @@ -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()) } } @@ -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";