diff --git a/src/grammar.pest b/src/grammar.pest index e99471b..58f0e42 100644 --- a/src/grammar.pest +++ b/src/grammar.pest @@ -8,7 +8,7 @@ block = { "{" ~ MLF ~ block_line ~ MLF ~ "}" } block_line = _{ expr | (statement ~ MLF)* } type_decl = { "type" ~ #name = type_ident ~ "=" ~ type_expr } -type_expr = { type_term | func | type_ident } +type_expr = { func | type_term | type_ident } type_term = _{ tuple | rec | enum | type_ident } tuple = { "#(" ~ MLF ~ tuple_entry* ~ MLF ~ ")" } diff --git a/src/test/types.rs b/src/test/types.rs index 86a4fef..365d2ad 100644 --- a/src/test/types.rs +++ b/src/test/types.rs @@ -75,3 +75,10 @@ fn it_parses_generics() { panic!("{e}") } } + +#[test] +fn it_parses_functions() { + if let Err(e) = (*TESTER).evaluate_strict("functions") { + panic!("{e}") + } +} diff --git a/tests/corpus/types/functions.txt b/tests/corpus/types/functions.txt new file mode 100644 index 0000000..e73b823 --- /dev/null +++ b/tests/corpus/types/functions.txt @@ -0,0 +1,37 @@ +Recs Test + +====== + +type MyFn = Num -> Num -> Str + +====== + +(file + (statement + (type_decl + (type_ident + (ident: "MyFn") + ) + (type_expr + (func + (type_ident + (ident: "Num") + ) + (type_expr + (func + (type_ident + (ident: "Num") + ) + (type_expr + (type_ident + (ident: "Str") + ) + ) + ) + ) + ) + ) + ) + ) + (EOI: "") +)