azdavis / millet

A language server for Standard ML.
https://azdavis.net/posts/millet
Apache License 2.0
210 stars 12 forks source link

Not all relevant type variables are considered when reporting types #38

Closed azdavis closed 1 year ago

azdavis commented 1 year ago

Environment

Steps to reproduce

something like these:

fun const x _ = x
fun swap (a, b) = (b, a)

Expected behavior

types are reported correctly in e.g. inlay hints or hover for ty

Actual behavior

types are reported incorrectly sometimes: compare the hover type (correct) vs inlay hints (wrong)

const

also see this test for swap

Fix

as in the comment, we might need to do something like consider the 'overall' type of the whole declaration so that we include all of the meta var names for each of the type bits instead of just considering the small bit of the overall dec type itself. (yes i know decs don't have types but i'm using "dec type" as a shorthand for "type of the top level pattern/exp of the val bind in the val dec".)

we may also want to use this 'overall' type anyway so we get the type scheme, which gives us proper bound type variables like 'a instead of meta type variables like ?a.

azdavis commented 1 year ago

This is solved with GeneralizedMetaVar and related machinery.