improve error reporting for underscore expr

This commit is contained in:
Folkert 2021-04-12 20:48:58 +02:00
parent 46ab922dd1
commit 2bb1f2cca7
6 changed files with 93 additions and 12 deletions

View file

@ -2,7 +2,7 @@ use roc_collections::all::MutSet;
use roc_module::ident::Lowercase;
use roc_parse::parser::{Col, Row};
use roc_problem::can::PrecedenceProblem::BothNonAssociative;
use roc_problem::can::{FloatErrorKind, IntErrorKind, Problem, RuntimeError};
use roc_problem::can::{BadPattern, FloatErrorKind, IntErrorKind, Problem, RuntimeError};
use roc_region::all::Region;
use std::path::PathBuf;
@ -103,7 +103,11 @@ pub fn can_problem<'b>(
},
alloc.region(region),
]),
Problem::UnsupportedPattern(pattern_type, region) => {
Problem::UnsupportedPattern(BadPattern::UnderscoreInDef, region) => alloc.stack(vec![
alloc.reflow("Underscore patterns are not allowed in definitions"),
alloc.region(region),
]),
Problem::UnsupportedPattern(BadPattern::Unsupported(pattern_type), region) => {
use roc_parse::pattern::PatternType::*;
let this_thing = match pattern_type {