escalier-lang / escalier

A compile-to-JavaScript language with tight TypeScript integration.
https://escalier-lang.github.io/escalier/
MIT License
21 stars 1 forks source link

Make sure higher ranked type unify correctly #695

Open kevinbarabash opened 1 year ago

kevinbarabash commented 1 year ago

Test cases:

let identity = fn <T>(item: T) -> T => item     // generic
let plusOne = fn (x: number) -> number => x + 1 // concrete
let plusOne' = fn<T: number>(x: T) -> T => x + 1 // this has the same issues as plusOne

type Id<T> = (item: T) => T;
let x: Id<number> = identity; // fine
let y: Id<number> = plusOne; // fine

type IdHigherRank = <T,>(item: T) => T;
let z: IdHigherRank = identity; // fine
let zz: IdHigherRank = plusOne; // error
type HigherConstrained = <T extends string>(a0: T) => T;
let xy: HigherConstrained = <T,>(a0: T): T => a0;