Skip to content

Commit

Permalink
Merge pull request #6881 from roc-lang/empty-open-union
Browse files Browse the repository at this point in the history
fix openness inference for empty tag
  • Loading branch information
Anton-4 authored Jul 9, 2024
2 parents b9a17f4 + 4341c37 commit 0d9db5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
18 changes: 5 additions & 13 deletions crates/compiler/can/src/annotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,19 +968,10 @@ fn can_annotation_help(
);

if tags.is_empty() {
match ext {
Some(_) => {
// just `a` does not mean the same as `[]`, so even
// if there are no fields, still make this a `TagUnion`,
// not an EmptyTagUnion
Type::TagUnion(
Default::default(),
TypeExtension::from_type(ext_type, is_implicit_openness),
)
}

None => Type::EmptyTagUnion,
}
Type::TagUnion(
Default::default(),
TypeExtension::from_type(ext_type, is_implicit_openness),
)
} else {
let mut tag_types = can_tags(
env,
Expand Down Expand Up @@ -1173,6 +1164,7 @@ fn can_extension_type(
local_aliases,
references,
);

if valid_extension_type(shallow_dealias_with_scope(scope, &ext_type)) {
if matches!(loc_ann.extract_spaces().item, TypeAnnotation::Wildcard)
&& matches!(ext_problem_kind, ExtensionTypeKind::TagUnion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ app "test" provides [main] to "./platform"
walkHelp : {} -> [Continue {}, Break []]

main = when walkHelp {} is
# ^^^^^^^^^^^ [Break [], Continue {}]
# ^^^^^^^^^^^ [Break []w_a, Continue {}]
Continue {} -> {}

0 comments on commit 0d9db5b

Please sign in to comment.