From 2ec8649456254f461933501fddcfeafb37ceabc5 Mon Sep 17 00:00:00 2001 From: Sam Vervaeck Date: Wed, 14 Sep 2022 23:09:22 +0200 Subject: [PATCH] Fix bug in enum-declaration inference and fix some type errors --- src/checker.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/checker.ts b/src/checker.ts index d806e404c..ae43a3f66 100644 --- a/src/checker.ts +++ b/src/checker.ts @@ -702,8 +702,8 @@ abstract class SchemeBase { class Forall extends SchemeBase { public constructor( - public typeVars: TVar[], - public constraints: Constraint[], + public typeVars: Iterable, + public constraints: Iterable, public type: Type, ) { super(); @@ -1423,16 +1423,15 @@ export class Checker { this.addBinding(node.name.text, new Forall([], [], type)); return type; } - assert(scheme.typeVars.length === 0); - assert(scheme.constraints.length === 0); + assert(isEmpty(scheme.typeVars)); + assert(isEmpty(scheme.constraints)); return scheme.type; } case SyntaxKind.AppTypeExpression: { - const argTypes = node.args.map(arg => this.inferTypeExpression(arg, introduceTypeVars)); return TApp.build([ - ...argTypes, + ...node.args.map(arg => this.inferTypeExpression(arg, introduceTypeVars)), this.inferTypeExpression(node.operator, introduceTypeVars), ]); } @@ -1770,7 +1769,7 @@ export class Checker { { const argTypes = member.elements.map(el => this.inferTypeExpression(el)); elementType = new TArrow(argTypes, TApp.build([ ...kindArgs, type ])); - parentEnv.add(member.name.text, new Forall([], [], elementType)); + parentEnv.add(member.name.text, new Forall(typeVars, constraints, elementType)); break; } // TODO