···4747 /// Mapping from types to constructor names in the current module (or the prelude)
4848 pub module_types_constructors: HashMap<EcoString, TypeVariantConstructors>,
49495050+ pub module_type_aliases: HashMap<EcoString, TypeAliasConstructor>,
5151+5052 /// Values defined in the current module (or the prelude)
5153 pub module_values: HashMap<EcoString, ValueConstructor>,
5254···115117 entity_usages: vec![HashMap::new()],
116118 target_support,
117119 names,
120120+ module_type_aliases: HashMap::new(),
118121 }
119122 }
120123}
···311314 let name = type_name.clone();
312315 let location = info.origin;
313316 match self.module_types.insert(type_name, info) {
317317+ None => Ok(()),
318318+ Some(prelude_type) if is_prelude_module(&prelude_type.module) => Ok(()),
319319+ Some(previous) => Err(Error::DuplicateTypeName {
320320+ name,
321321+ location,
322322+ previous_location: previous.origin,
323323+ }),
324324+ }
325325+ }
326326+327327+ /// Map a type alias in the current scope.
328328+ /// Errors if the module already has a type with that name, unless the type is from the
329329+ /// prelude.
330330+ ///
331331+ pub fn insert_type_alias(
332332+ &mut self,
333333+ type_name: EcoString,
334334+ info: TypeAliasConstructor,
335335+ ) -> Result<(), Error> {
336336+ let name = type_name.clone();
337337+ let location = info.origin;
338338+ match self.module_type_aliases.insert(type_name, info) {
314339 None => Ok(()),
315340 Some(prelude_type) if is_prelude_module(&prelude_type.module) => Ok(()),
316341 Some(previous) => Err(Error::DuplicateTypeName {