Able variables through different functions compile

This commit is contained in:
Ayaz Hafiz 2022-04-19 13:09:40 -04:00
parent a07323fb40
commit b9f79fdd31
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 27 additions and 0 deletions

View file

@ -478,6 +478,10 @@ pub fn canonicalize_defs<'a>(
}
};
if pattern_type == PatternType::TopLevelDef {
env.top_level_symbols.insert(member_sym);
}
// What variables in the annotation are bound to the parent ability, and what variables
// are bound to some other ability?
let (variables_bound_to_ability, variables_bound_to_other_abilities): (Vec<_>, Vec<_>) =

View file

@ -84,3 +84,26 @@ fn alias_member_specialization() {
u64
);
}
#[test]
fn ability_constrained_in_non_member_usage() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [ result ] to "./platform"
Hash has
hash : a -> U64 | a has Hash
mulHashes = \x, y -> hash x * hash y
Id := U64
hash = \$Id n -> n
result = mulHashes ($Id 5) ($Id 7)
"#
),
35,
u64
)
}