mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
accept a newline and body when patterns are different
This commit is contained in:
parent
1b4c5cac25
commit
58dfeba043
3 changed files with 32 additions and 1 deletions
|
@ -151,7 +151,7 @@ pub fn canonicalize_defs<'a>(
|
|||
match iter.peek() {
|
||||
Some(Located {
|
||||
value: Body(body_pattern, body_expr),
|
||||
..
|
||||
region: body_region,
|
||||
}) => {
|
||||
if pattern.value.equivalent(&body_pattern.value) {
|
||||
iter.next();
|
||||
|
@ -165,6 +165,10 @@ pub fn canonicalize_defs<'a>(
|
|||
&mut scope,
|
||||
pattern_type,
|
||||
)
|
||||
} else if loc_def.region.lines_between(body_region) > 1 {
|
||||
// there is a line of whitespace between the annotation and the body
|
||||
// treat annotation and body separately
|
||||
to_pending_def(env, var_store, &loc_def.value, &mut scope, pattern_type)
|
||||
} else {
|
||||
// the pattern of the annotation does not match the pattern of the body directly below it
|
||||
env.problems.push(Problem::SignatureDefMismatch {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue