mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
Merge branch 'trunk' into incompatible_type_param
This commit is contained in:
commit
b35eb85e03
2 changed files with 27 additions and 10 deletions
|
@ -4131,17 +4131,17 @@ fn convert_tag_union<'a>(
|
||||||
hole,
|
hole,
|
||||||
),
|
),
|
||||||
ByteUnion(tag_names) => {
|
ByteUnion(tag_names) => {
|
||||||
let tag_id = tag_names
|
let opt_tag_id = tag_names.iter().position(|key| key == &tag_name);
|
||||||
.iter()
|
|
||||||
.position(|key| key == &tag_name)
|
|
||||||
.expect("tag must be in its own type");
|
|
||||||
|
|
||||||
Stmt::Let(
|
match opt_tag_id {
|
||||||
|
Some(tag_id) => Stmt::Let(
|
||||||
assigned,
|
assigned,
|
||||||
Expr::Literal(Literal::Byte(tag_id as u8)),
|
Expr::Literal(Literal::Byte(tag_id as u8)),
|
||||||
Layout::Builtin(Builtin::Int8),
|
Layout::Builtin(Builtin::Int8),
|
||||||
hole,
|
hole,
|
||||||
)
|
),
|
||||||
|
None => Stmt::RuntimeError("tag must be in its own type"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Newtype {
|
Newtype {
|
||||||
|
|
|
@ -1033,3 +1033,20 @@ fn applied_tag_function_linked_list() {
|
||||||
i64
|
i64
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[should_panic(expected = "")]
|
||||||
|
fn tag_must_be_its_own_type() {
|
||||||
|
assert_evals_to!(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
z : [ A, B, C ]
|
||||||
|
z = Z
|
||||||
|
|
||||||
|
z
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
i64
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue