mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +00:00
Solve derived impls
This commit is contained in:
parent
c5d970bd81
commit
95e325296f
3 changed files with 12 additions and 28 deletions
|
@ -908,7 +908,7 @@ fn canonicalize_has_clause(
|
|||
var_store: &mut VarStore,
|
||||
introduced_variables: &mut IntroducedVariables,
|
||||
clause: &Loc<roc_parse::ast::HasClause<'_>>,
|
||||
abilities_in_scope: &[Symbol],
|
||||
abilities_in_local_scope: &[Symbol],
|
||||
references: &mut VecSet<Symbol>,
|
||||
) -> Result<(), Type> {
|
||||
let Loc {
|
||||
|
@ -927,7 +927,12 @@ fn canonicalize_has_clause(
|
|||
let ability = match ability.value {
|
||||
TypeAnnotation::Apply(module_name, ident, _type_arguments) => {
|
||||
let symbol = make_apply_symbol(env, ability.region, scope, module_name, ident)?;
|
||||
if !abilities_in_scope.contains(&symbol) {
|
||||
|
||||
// Ability defined locally, whose members we are constructing right now...
|
||||
if !abilities_in_local_scope.contains(&symbol)
|
||||
// or an ability that was imported from elsewhere
|
||||
&& !scope.abilities_store.is_ability(symbol)
|
||||
{
|
||||
let region = ability.region;
|
||||
env.problem(roc_problem::can::Problem::HasClauseIsNotAbility { region });
|
||||
return Err(Type::Erroneous(Problem::HasClauseIsNotAbility(region)));
|
||||
|
|
|
@ -255,12 +255,12 @@ pub fn canonicalize_module_defs<'a>(
|
|||
{
|
||||
// These are not aliases but Apply's and we make sure they are always in scope
|
||||
} else {
|
||||
// This is a type alias
|
||||
// This is a type alias or ability
|
||||
|
||||
// the symbol should already be added to the scope when this module is canonicalized
|
||||
debug_assert!(
|
||||
scope.contains_alias(symbol),
|
||||
"The {:?} is not a type alias known in {:?}",
|
||||
scope.contains_alias(symbol) || scope.abilities_store.is_ability(symbol),
|
||||
"The {:?} is not a type alias or ability known in {:?}",
|
||||
symbol,
|
||||
home
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue