fix enum and bool pattern match suggestions

This commit is contained in:
Folkert 2020-04-12 21:19:50 +02:00
parent 7632a4b484
commit c69b0d69e5
6 changed files with 136 additions and 50 deletions

View file

@ -155,7 +155,7 @@ pub fn mono_problem<'b>(
PatternProblem(Incomplete(region, context, missing)) => match context {
BadArg => {
let doc = alloc.stack(vec![
alloc.reflow("This pattern does not cover all the possibilities"),
alloc.reflow("This pattern does not cover all the possibilities:"),
alloc.region(region),
alloc.reflow("Other possibilities include:"),
unhandled_patterns_to_doc_block(alloc, missing),
@ -177,7 +177,7 @@ pub fn mono_problem<'b>(
}
BadDestruct => {
let doc = alloc.stack(vec![
alloc.reflow("This pattern does not cover all the possibilities"),
alloc.reflow("This pattern does not cover all the possibilities:"),
alloc.region(region),
alloc.reflow("Other possibilities include:"),
unhandled_patterns_to_doc_block(alloc, missing),
@ -203,7 +203,7 @@ pub fn mono_problem<'b>(
alloc.concat(vec![
alloc.reflow("This "),
alloc.keyword("when"),
alloc.reflow(" does not cover all the possibilities"),
alloc.reflow(" does not cover all the possibilities:"),
]),
alloc.region(region),
alloc.reflow("Other possibilities include:"),

View file

@ -160,7 +160,7 @@ fn to_expr_report<'b>(
None => (alloc.text("this"), alloc.nil()),
};
let mut region = None;
let mut sub_region = None;
let thing = match annotation_source {
TypedIfBranch {
@ -189,7 +189,7 @@ fn to_expr_report<'b>(
alloc.text(" expression:"),
]),
TypedBody { region: ann_region } => {
region = Some(ann_region);
sub_region = Some(ann_region);
alloc.concat(vec![
alloc.text("body of "),
the_name_text,
@ -222,9 +222,10 @@ fn to_expr_report<'b>(
filename,
doc: alloc.stack(vec![
alloc.text("Something is off with the ").append(thing),
match region {
match sub_region {
None => alloc.region(expr_region),
Some(ann_region) => {
// for typed bodies, include the line(s) have the signature
let joined =
roc_region::all::Region::span_across(&ann_region, &expr_region);
alloc.region_with_subregion(joined, expr_region)