tag must be its own type fix

This commit is contained in:
Eric Correia 2021-07-03 12:06:48 -04:00
parent 28520b2cf4
commit 8deb377d30
2 changed files with 28 additions and 10 deletions

View file

@ -4126,17 +4126,18 @@ fn convert_tag_union<'a>(
hole,
),
ByteUnion(tag_names) => {
let tag_id = tag_names
.iter()
.position(|key| key == &tag_name)
.expect("tag must be in its own type");
let opt_tag_id = tag_names.iter().position(|key| key == &tag_name);
// .expect("tag must be in its own type");
Stmt::Let(
assigned,
Expr::Literal(Literal::Byte(tag_id as u8)),
Layout::Builtin(Builtin::Int8),
hole,
)
match opt_tag_id {
Some(tag_id) => Stmt::Let(
assigned,
Expr::Literal(Literal::Byte(tag_id as u8)),
Layout::Builtin(Builtin::Int8),
hole,
),
None => Stmt::RuntimeError("tag must be in its own type"),
}
}
Newtype {