added tests for unbound type variables
@@ -354,3 +354,24 @@ fn line_comments() {
parse_without_pos("{field = foo}")
);
}
+
+#[test]
+fn unbound_type_variables() {
+ // should fail, "a" is unbound
+ assert_matches!(
+ parse("1 | a"),
+ Err(ParseError::UnboundTypeVariable(unbound_vars)) if (unbound_vars.contains(&Ident("a".into())) && unbound_vars.len() == 1)
+ );
+
+ // should fail, "d" is unbound
+ assert_matches!(
+ parse("null: forall a b c. a -> (b -> List c) -> {foo : List {_ : d}, bar: b | Dyn}"),
+ Err(ParseError::UnboundTypeVariable(unbound_vars)) if (unbound_vars.contains(&Ident("d".into())) && unbound_vars.len() == 1)
+ );
+
+ // should fail, "e" is unbound
+ assert_matches!(
+ parse("null: forall a b c. a -> (b -> List c) -> {foo : List {_ : a}, bar: b | e}"),
+ Err(ParseError::UnboundTypeVariable(unbound_vars)) if (unbound_vars.contains(&Ident("e".into())) && unbound_vars.len() == 1)
+ );
+}
