From 31e99fd8bae4b9ebc908aa0100865d360c69304f Mon Sep 17 00:00:00 2001 From: Sam Vervaeck Date: Thu, 15 Sep 2022 20:48:36 +0200 Subject: [PATCH] Clean up some code and fix all TypeScript type errors --- src/checker.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/checker.ts b/src/checker.ts index 43a9e0e35..5560b4e9b 100644 --- a/src/checker.ts +++ b/src/checker.ts @@ -1,11 +1,9 @@ import { Declaration, EnumDeclaration, - EnumDeclarationStructElement, Expression, LetDeclaration, Pattern, - Scope, SourceFile, StructDeclaration, Symkind, @@ -366,7 +364,7 @@ export class TNominal extends TypeBase { public readonly kind = TypeKind.Nominal; public constructor( - public decl: Declaration, + public decl: StructDeclaration | EnumDeclaration, public node: Syntax | null = null, ) { super(node); @@ -383,7 +381,7 @@ export class TNominal extends TypeBase { ); } - public substitute(sub: TVSub): Type { + public substitute(_sub: TVSub): Type { return this; } @@ -1912,11 +1910,11 @@ export class Checker { } if (left.kind === TypeKind.Nominal && right.kind === TypeKind.Nominal) { - if (left.decl !== right.decl) { - this.diagnostics.add(new UnificationFailedDiagnostic(left, right, [...constraint.getNodes()])); - return false; + if (left.decl === right.decl) { + return true; } - return true; + this.diagnostics.add(new UnificationFailedDiagnostic(left, right, [...constraint.getNodes()])); + return false; } if (left.kind === TypeKind.App && right.kind === TypeKind.App) { @@ -1925,10 +1923,6 @@ export class Checker { } if (left.kind === TypeKind.Record && right.kind === TypeKind.Record) { - if (left.decl !== right.decl) { - this.diagnostics.add(new UnificationFailedDiagnostic(left, right, [...constraint.getNodes()])); - return false; - } let success = true; const remaining = new Set(right.fields.keys()); for (const [fieldName, fieldType] of left.fields) {