mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-15 17:05:03 +01:00
fix type inference
This commit is contained in:
parent
162d71c8b8
commit
e88d0f8782
2 changed files with 37 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { TY_INT, TY_STRING } from "./ast";
|
||||
import { TY_INT, TY_STRING, TY_UNIT } from "./ast";
|
||||
import { DUMMY_SPAN as SPAN } from "./error";
|
||||
import { InferContext } from "./typeck";
|
||||
|
||||
|
|
@ -34,3 +34,21 @@ it("should conflict assignments to resolvable type vars", () => {
|
|||
|
||||
expect(() => infcx.assign(a, TY_STRING, SPAN)).toThrow();
|
||||
});
|
||||
|
||||
it("should not cycle", () => {
|
||||
const infcx = new InferContext();
|
||||
|
||||
const a = infcx.newVar();
|
||||
const b = infcx.newVar();
|
||||
|
||||
infcx.assign(a, b, SPAN);
|
||||
infcx.assign(b, a, SPAN);
|
||||
|
||||
const aType = infcx.resolveIfPossible(a);
|
||||
expect(aType.kind).toEqual("var");
|
||||
|
||||
infcx.assign(a, TY_UNIT, SPAN);
|
||||
|
||||
const bType = infcx.resolveIfPossible(b);
|
||||
expect(bType.kind).toEqual("tuple");
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue