Canonicalization of list patterns

This commit is contained in:
Ayaz Hafiz 2022-10-31 11:57:02 -05:00
parent 55ea3bbea2
commit b0a8b85de3
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
13 changed files with 189 additions and 4 deletions

View file

@ -1,7 +1,7 @@
use crate::{
def::Def,
expr::{AccessorData, ClosureData, Expr, Field, OpaqueWrapFunctionData, WhenBranchPattern},
pattern::{DestructType, Pattern, RecordDestruct},
pattern::{DestructType, ListPatterns, Pattern, RecordDestruct},
};
use roc_module::{
ident::{Lowercase, TagName},
@ -707,6 +707,18 @@ fn deep_copy_pattern_help<C: CopyEnv>(
})
.collect(),
},
List {
list_var,
elem_var,
patterns: ListPatterns { patterns, opt_rest },
} => List {
list_var: sub!(*list_var),
elem_var: sub!(*elem_var),
patterns: ListPatterns {
patterns: patterns.iter().map(|lp| lp.map(|p| go_help!(p))).collect(),
opt_rest: *opt_rest,
},
},
NumLiteral(var, s, n, bound) => NumLiteral(sub!(*var), s.clone(), *n, *bound),
IntLiteral(v1, v2, s, n, bound) => IntLiteral(sub!(*v1), sub!(*v2), s.clone(), *n, *bound),
FloatLiteral(v1, v2, s, n, bound) => {