implement canonicalization error when signature pattern does not match definition pattern.

This commit is contained in:
Folkert 2020-07-02 23:24:10 +02:00
parent 5c81b46d1c
commit 0cfb16c7d5
4 changed files with 55 additions and 1 deletions

View file

@ -168,7 +168,15 @@ pub fn canonicalize_defs<'a>(
pattern_type,
)
} else {
panic!("TODO gracefully handle the case where a type annotation appears immediately before a body def, but the patterns are different. This should be an error; put a newline or comment between them!");
// the pattern of the annotation does not match the pattern of the body directly below it
env.problems.push(Problem::SignatureDefMismatch {
annotation_pattern: pattern.region,
def_pattern: body_pattern.region,
});
// both the annotation and definition are skipped!
iter.next();
continue;
}
}
_ => to_pending_def(env, var_store, &loc_def.value, &mut scope, pattern_type),