diff --git a/crates/aiken-lang/src/parser.rs b/crates/aiken-lang/src/parser.rs index a639234f..59779bf9 100644 --- a/crates/aiken-lang/src/parser.rs +++ b/crates/aiken-lang/src/parser.rs @@ -1519,7 +1519,7 @@ pub fn type_parser() -> impl Parser .then( r.separated_by(just(Token::Comma)) .allow_trailing() - .delimited_by(just(Token::LeftParen), just(Token::RightParen)) + .delimited_by(just(Token::Less), just(Token::Greater)) .or_not(), ) .or_not(), diff --git a/crates/aiken-lang/src/tests/parser.rs b/crates/aiken-lang/src/tests/parser.rs index c3bd9a36..605c61b0 100644 --- a/crates/aiken-lang/src/tests/parser.rs +++ b/crates/aiken-lang/src/tests/parser.rs @@ -38,6 +38,55 @@ fn windows_newline() { ) } +#[test] +fn type_annotation_with_module_prefix() { + let code = indoc! {r#" + use aiken + + pub fn go() -> aiken.Option { + False + } + "#}; + + assert_definitions( + code, + vec![ + ast::UntypedDefinition::Use(ast::Use { + as_name: None, + location: Span::new((), 0..9), + module: vec!["aiken".to_string()], + package: (), + unqualified: vec![], + }), + ast::UntypedDefinition::Fn(ast::Function { + arguments: vec![], + body: expr::UntypedExpr::Var { + location: Span::new((), 48..53), + name: "False".to_string(), + }, + doc: None, + location: Span::new((), 11..43), + name: "go".to_string(), + public: true, + return_annotation: Some(ast::Annotation::Constructor { + location: Span::new((), 26..43), + module: Some("aiken".to_string()), + name: "Option".to_string(), + arguments: vec![ast::Annotation::Constructor { + location: Span::new((), 39..42), + module: None, + name: "Int".to_string(), + arguments: vec![], + }], + }), + return_type: (), + end_position: 54, + can_error: true, + }), + ], + ) +} + #[test] fn test_fail() { let code = indoc! {r#"