Skip to content

kind inference: report a kind error for wrong-kinded type alias arguments#904

Open
alpaylan wants to merge 1 commit into
koka-lang:devfrom
alpaylan:dev
Open

kind inference: report a kind error for wrong-kinded type alias arguments#904
alpaylan wants to merge 1 commit into
koka-lang:devfrom
alpaylan:dev

Conversation

@alpaylan

@alpaylan alpaylan commented Jul 7, 2026

Copy link
Copy Markdown

The snippet below previously produced an internal error (I believe the same one in #598):

type myeff :: X

alias property<e> = () -> e bool

fun check(prop : property<myeff>) : ()
  ()

Applying a type alias to an argument of the wrong kind (e.g.
alias property<e> = () -> e bool used as property<console> where
e :: E but console :: X, or issue #598's stream<a,div>) crashed
the compiler with an internal assertion (Type.TypeVar.subNew.KindMismatch)
instead of reporting an error, since resolveApp substituted alias
arguments without checking their kinds.

Check each parameter/argument pair: on a kind mismatch, report a
standard kind error (via kindError, now exported from Kind.Unify) and
substitute the parameter for itself to keep the expansion substitution
well-kinded.

…ents

Applying a type alias to an argument of the wrong kind (e.g.
`alias property<e> = () -> e bool` used as `property<console>` where
`e :: E` but `console :: X`, or issue koka-lang#598's `stream<a,div>`) crashed
the compiler with an internal assertion (Type.TypeVar.subNew.KindMismatch)
instead of reporting an error, since resolveApp substituted alias
arguments without checking their kinds.

Check each parameter/argument pair: on a kind mismatch, report a
standard kind error (via kindError, now exported from Kind.Unify) and
substitute the parameter for itself to keep the expansion substitution
well-kinded.

Fixes koka-lang#598
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant