fix: bad parsing for module select type annotations closes #550
This commit is contained in:
parent
28a9152f09
commit
2860bac4c6
|
@ -1519,7 +1519,7 @@ pub fn type_parser() -> impl Parser<Token, ast::Annotation, Error = ParseError>
|
||||||
.then(
|
.then(
|
||||||
r.separated_by(just(Token::Comma))
|
r.separated_by(just(Token::Comma))
|
||||||
.allow_trailing()
|
.allow_trailing()
|
||||||
.delimited_by(just(Token::LeftParen), just(Token::RightParen))
|
.delimited_by(just(Token::Less), just(Token::Greater))
|
||||||
.or_not(),
|
.or_not(),
|
||||||
)
|
)
|
||||||
.or_not(),
|
.or_not(),
|
||||||
|
|
|
@ -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<Int> {
|
||||||
|
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]
|
#[test]
|
||||||
fn test_fail() {
|
fn test_fail() {
|
||||||
let code = indoc! {r#"
|
let code = indoc! {r#"
|
||||||
|
|
Loading…
Reference in New Issue