diff --git a/schala-lang/language/src/parsing/new.rs b/schala-lang/language/src/parsing/new.rs index 1aba2a3..1ba59d9 100644 --- a/schala-lang/language/src/parsing/new.rs +++ b/schala-lang/language/src/parsing/new.rs @@ -109,10 +109,10 @@ peg::parser! { alias:identifier() _ "=" _ name:identifier() { Declaration::TypeAlias { alias: rc_string(alias), original: rc_string(name), } } rule type_anno() -> TypeIdentifier = - ":" _ ident:identifier() { TypeIdentifier::Singleton(TypeSingletonName { name: Rc::new(ident.to_string()), params: vec![] }) } + ":" _ identifier:type_identifier() { identifier } pub rule expression() -> Expression = - _ kind:expression_kind() { Expression { id: Default::default(), type_anno: None, kind: kind } } + _ kind:expression_kind() _ type_anno:type_anno()? { Expression { id: Default::default(), type_anno, kind: kind } } rule expression_no_struct() -> Expression = _ kind:expression_kind_no_struct() { Expression { id: Default::default(), type_anno: None, kind: kind } } diff --git a/schala-lang/language/src/parsing/test.rs b/schala-lang/language/src/parsing/test.rs index 0069c34..f7b0c4f 100644 --- a/schala-lang/language/src/parsing/test.rs +++ b/schala-lang/language/src/parsing/test.rs @@ -547,7 +547,7 @@ fn type_annotations() { use ExpressionKind::*; use TypeIdentifier::*; - assert_ast!( + assert_ast2!( "let a = b : Int", vec![decl(Declaration::Binding { name: rc("a"), @@ -557,11 +557,11 @@ fn type_annotations() { })] ); - assert_expr!( + assert_expr2!( "a: Int", expr_anno(Value(qn!(a)), Singleton(TypeSingletonName { name: rc("Int"), params: vec![] })) ); - assert_expr!( + assert_expr2!( "a: Option", expr_anno( Value(qn!(a)), @@ -571,7 +571,7 @@ fn type_annotations() { }) ) ); - assert_expr!( + assert_expr2!( "a: KoreanBBQSpecifier >", expr_anno( Value(qn!(a)), @@ -587,7 +587,7 @@ fn type_annotations() { }) ) ); - assert_expr!( + assert_expr2!( "a: (Int, Yolo)", expr_anno( Value(qn!(a)),