From 947b6d874004a2e61c56ff74d409405db0782e13 Mon Sep 17 00:00:00 2001 From: Sam Vervaeck Date: Sun, 19 Mar 2023 15:04:47 +0100 Subject: [PATCH] Manually filter out type variables in type scheme that do nothing --- src/checker.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/checker.ts b/src/checker.ts index e37365223..0835dc756 100644 --- a/src/checker.ts +++ b/src/checker.ts @@ -838,10 +838,12 @@ class Forall extends SchemeBase { public type: Type, ) { super(); - if (typeVars instanceof TVSet) { - this.typeVars = typeVars; - } else { - this.typeVars = new TVSet(typeVars); + this.typeVars = new TVSet(); + const allowed = new TVSet(type.getTypeVars()); + for (const tv of typeVars) { + if (allowed.has(tv)) { + this.typeVars.add(tv); + } } }