mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +00:00
fix enum and bool pattern match suggestions
This commit is contained in:
parent
7632a4b484
commit
c69b0d69e5
6 changed files with 136 additions and 50 deletions
|
@ -420,13 +420,13 @@ fn test_at_path<'a>(selected_path: &Path, branch: Branch<'a>, all_tests: &mut Ve
|
|||
arguments: arguments.to_vec(),
|
||||
});
|
||||
}
|
||||
BitLiteral(v) => {
|
||||
all_tests.push(IsBit(*v));
|
||||
BitLiteral { value, .. } => {
|
||||
all_tests.push(IsBit(*value));
|
||||
}
|
||||
EnumLiteral { tag_id, enum_size } => {
|
||||
EnumLiteral { tag_id, union, .. } => {
|
||||
all_tests.push(IsByte {
|
||||
tag_id: *tag_id,
|
||||
num_alts: *enum_size as usize,
|
||||
num_alts: union.alternatives.len(),
|
||||
});
|
||||
}
|
||||
IntLiteral(v) => {
|
||||
|
@ -629,7 +629,7 @@ fn to_relevant_branch_help<'a>(
|
|||
_ => None,
|
||||
},
|
||||
|
||||
BitLiteral(bit) => match test {
|
||||
BitLiteral { value: bit, .. } => match test {
|
||||
IsBit(test_bit) if bit == *test_bit => {
|
||||
start.extend(end);
|
||||
Some(Branch {
|
||||
|
@ -714,7 +714,7 @@ fn needs_tests<'a>(pattern: &Pattern<'a>) -> bool {
|
|||
|
||||
RecordDestructure(_, _)
|
||||
| AppliedTag { .. }
|
||||
| BitLiteral(_)
|
||||
| BitLiteral { .. }
|
||||
| EnumLiteral { .. }
|
||||
| IntLiteral(_)
|
||||
| FloatLiteral(_)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue