mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
Give an error instead of panicking on an empty tuple type
This commit is contained in:
parent
861f9c5d47
commit
cbd6d50584
5 changed files with 35 additions and 25 deletions
|
@ -9,7 +9,7 @@ use crate::scope::{PendingAbilitiesInScope, Scope};
|
|||
use roc_exhaustive::ListArity;
|
||||
use roc_module::ident::{Ident, Lowercase, TagName};
|
||||
use roc_module::symbol::Symbol;
|
||||
use roc_parse::ast::{self, StrLiteral, StrSegment};
|
||||
use roc_parse::ast::{self, ExtractSpaces, StrLiteral, StrSegment};
|
||||
use roc_parse::pattern::PatternType;
|
||||
use roc_problem::can::{MalformedPatternProblem, Problem, RuntimeError, ShadowKind};
|
||||
use roc_region::all::{Loc, Region};
|
||||
|
@ -476,7 +476,14 @@ pub fn canonicalize_pattern<'a>(
|
|||
Pattern::OpaqueNotInScope(Loc::at(tag.region, name.into()))
|
||||
}
|
||||
},
|
||||
_ => unreachable!("Other patterns cannot be applied"),
|
||||
_ => {
|
||||
env.problem(Problem::RuntimeError(RuntimeError::MalformedPattern(
|
||||
MalformedPatternProblem::CantApplyPattern,
|
||||
tag.region,
|
||||
)));
|
||||
|
||||
Pattern::UnsupportedPattern(region)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -817,7 +824,7 @@ pub fn canonicalize_record_destructs<'a>(
|
|||
let mut opt_erroneous = None;
|
||||
|
||||
for loc_pattern in patterns.iter() {
|
||||
match loc_pattern.value {
|
||||
match loc_pattern.value.extract_spaces().item {
|
||||
Identifier { ident: label } => {
|
||||
match scope.introduce(label.into(), region) {
|
||||
Ok(symbol) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue