diff --git a/Analysis/src/TypeInfer.cpp b/Analysis/src/TypeInfer.cpp index 4d34d56e..47fc46bd 100644 --- a/Analysis/src/TypeInfer.cpp +++ b/Analysis/src/TypeInfer.cpp @@ -1633,8 +1633,6 @@ void TypeChecker::prototype(const ScopePtr& scope, const AstStatTypeAlias& typea void TypeChecker::prototype(const ScopePtr& scope, const AstStatDeclareClass& declaredClass) { - Name className(declaredClass.name.value); - std::optional superTy = std::nullopt; if (declaredClass.superName) { @@ -1661,6 +1659,8 @@ void TypeChecker::prototype(const ScopePtr& scope, const AstStatDeclareClass& de } } + Name className(declaredClass.name.value); + TypeId classTy = addType(ClassTypeVar(className, {}, superTy, std::nullopt, {}, {}, currentModuleName)); ClassTypeVar* ctv = getMutable(classTy); TypeId metaTy = addType(TableTypeVar{TableState::Sealed, scope->level});