From f11ad9028e88cae49788a461c7b1feccec9e57be Mon Sep 17 00:00:00 2001 From: Sam Vervaeck Date: Thu, 15 Sep 2022 23:05:34 +0200 Subject: [PATCH] Fix wrong node being printed when diagnosing the origin of a type --- src/checker.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/checker.ts b/src/checker.ts index 4e3f3303d..e99a745df 100644 --- a/src/checker.ts +++ b/src/checker.ts @@ -1356,7 +1356,12 @@ export class Checker { return this.createTypeVar(); } type = this.instantiate(scheme, node.name); - // FIXME it is not guaranteed that `type` is copied, so the original type might get mutated + // It is not guaranteed that `type` is copied during instantiation, + // so the following check ensures that we really are holding a copy + // that we can mutate. + if (type === scheme.type) { + type = type.shallowClone(); + } type.node = node; break; }