Fix wrong node being printed when diagnosing the origin of a type

This commit is contained in:
Sam Vervaeck 2022-09-15 23:05:34 +02:00
parent 9bf81c56db
commit f11ad9028e

View file

@ -1356,7 +1356,12 @@ export class Checker {
return this.createTypeVar(); return this.createTypeVar();
} }
type = this.instantiate(scheme, node.name); 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; type.node = node;
break; break;
} }