From 0f245ba7788d03a992fe55d24293d6a10df3c8c5 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 23 Apr 2022 22:14:50 +0200 Subject: [PATCH] insert type aliases instead of relying on scope check --- compiler/can/src/def.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/can/src/def.rs b/compiler/can/src/def.rs index 8813071ef7..2a0c4341c9 100644 --- a/compiler/can/src/def.rs +++ b/compiler/can/src/def.rs @@ -321,6 +321,9 @@ pub(crate) fn canonicalize_defs<'a>( } } + // Determine which idents we introduced in the course of this process. + let mut symbols_introduced = MutMap::default(); + let sorted = sort_type_defs_before_introduction(referenced_type_symbols); let mut aliases = SendMap::default(); let mut abilities = MutMap::default(); @@ -328,6 +331,8 @@ pub(crate) fn canonicalize_defs<'a>( for type_name in sorted { match type_defs.remove(&type_name).unwrap() { TypeDef::AliasLike(name, vars, ann, kind) => { + symbols_introduced.insert(name.value, name.region); + let symbol = name.value; let can_ann = canonicalize_annotation( env, @@ -428,6 +433,8 @@ pub(crate) fn canonicalize_defs<'a>( } TypeDef::Ability(name, members) => { + symbols_introduced.insert(name.value, name.region); + // For now we enforce that aliases cannot reference abilities, so let's wait to // resolve ability definitions until aliases are resolved and in scope below. abilities.insert(name.value, (name, members)); @@ -488,9 +495,6 @@ pub(crate) fn canonicalize_defs<'a>( } } - // Determine which idents we introduced in the course of this process. - let mut symbols_introduced = MutMap::default(); - let mut symbol_to_index: Vec<(IdentId, u32)> = Vec::with_capacity(pending_value_defs.len()); for (def_index, pending_def) in pending_value_defs.iter().enumerate() {