From 9c24ddb07e7981fb23bb34acd540001f4a505082 Mon Sep 17 00:00:00 2001 From: Sam Vervaeck Date: Wed, 12 Apr 2023 14:26:39 +0200 Subject: [PATCH] Move 'type class exists' check to initialze() --- src/checker.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/checker.ts b/src/checker.ts index 8daead5bb..8fea7d7df 100644 --- a/src/checker.ts +++ b/src/checker.ts @@ -1481,10 +1481,6 @@ export class Checker { case SyntaxKind.InstanceDeclaration: { - const cls = node.getScope().lookup(node.name.text, Symkind.Typeclass) as ClassDeclaration | null; - if (cls === null) { - this.diagnostics.add(new TypeclassNotFoundDiagnostic(node.name)); - } for (const element of node.elements) { this.infer(element); } @@ -2008,6 +2004,9 @@ export class Checker { case SyntaxKind.InstanceDeclaration: { + if (!this.classDecls.has(node.name.text)) { + this.diagnostics.add(new TypeclassNotFoundDiagnostic(node.name)); + } const env = node.typeEnv = new TypeEnv(parentEnv); for (const element of node.elements) { this.initialize(element, env);