Fixes #921: top-level Miller-loop needs not to be serialisable

This is a bit tricky, but in a similar way where we allow functions to
  be returned by functions, this must also work for MillerLoopResult.
This commit is contained in:
KtorZ
2024-05-10 13:39:52 +02:00
parent 83c0566afb
commit 8c67be55ce
3 changed files with 77 additions and 14 deletions

View File

@@ -207,6 +207,53 @@ fn illegal_inhabitants_returned() {
))
}
#[test]
fn not_illegal_top_level_unserialisable() {
let source_code = r#"
fn foo() -> MillerLoopResult {
todo
}
"#;
assert!(check(parse(source_code)).is_ok());
}
#[test]
fn illegal_unserialisable_in_generic_fn() {
let source_code = r#"
type Foo<a> {
foo: a
}
fn main() -> Foo<fn(Int) -> Bool> {
todo
}
"#;
assert!(matches!(
check(parse(source_code)),
Err((_, Error::IllegalTypeInData { .. }))
))
}
#[test]
fn illegal_unserialisable_in_generic_miller_loop() {
let source_code = r#"
type Foo<a> {
foo: a
}
fn main() -> Foo<MillerLoopResult> {
todo
}
"#;
assert!(matches!(
check(parse(source_code)),
Err((_, Error::IllegalTypeInData { .. }))
))
}
#[test]
fn mark_constructors_as_used_via_field_access() {
let source_code = r#"