mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-01 10:52:18 +00:00
Make sure ability defs that are possibly recursive are marked as such
This commit is contained in:
parent
0525c6d616
commit
75ce40c67d
4 changed files with 18 additions and 2 deletions
|
@ -1530,6 +1530,13 @@ fn canonicalize_var_lookup(
|
|||
output.references.insert_value_lookup(symbol);
|
||||
|
||||
if scope.abilities_store.is_ability_member_name(symbol) {
|
||||
// Is there a shadow implementation with the same name? If so, we might be in
|
||||
// the def for that shadow. In that case add a value lookup of the shadow impl,
|
||||
// so that it's marked as possibly-recursive.
|
||||
if let Some(shadow) = scope.get_member_shadow(symbol) {
|
||||
output.references.insert_value_lookup(shadow.value);
|
||||
}
|
||||
|
||||
AbilityMember(
|
||||
symbol,
|
||||
Some(scope.abilities_store.fresh_specialization_id()),
|
||||
|
|
|
@ -205,6 +205,7 @@ pub fn canonicalize_def_header_pattern<'a>(
|
|||
}
|
||||
// Likely a specialization of an ability.
|
||||
Some(ability_member_name) => {
|
||||
output.references.insert_bound(symbol);
|
||||
output.references.insert_value_lookup(ability_member_name);
|
||||
Pattern::AbilityMemberSpecialization {
|
||||
ident: symbol,
|
||||
|
|
|
@ -348,6 +348,10 @@ impl Scope {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_member_shadow(&self, ability_member: Symbol) -> Option<&Loc<Symbol>> {
|
||||
self.shadows.get(&ability_member)
|
||||
}
|
||||
|
||||
/// Create a new symbol, but don't add it to the scope (yet)
|
||||
///
|
||||
/// Used for record guards like { x: Just _ } where the `x` is not added to the scope,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue