azdavis / millet

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

Signature / structure type mismatch location #57

Open vqns opened 5 months ago

vqns commented 5 months ago

Environment

Steps to reproduce

Structure / signature type mismatch for a given identifier seems to be reported at the start of the structure (i.e at the struct keyword) and only mentions incompatible types (5006). Example:

structure S :
sig
    val i : int
end =
struct
(* ^ error here *)
    val i = ""
end

Expected behavior

If possible, the location of the diagnostic should be that of the declaration in the structure. Or maybe mentioning either the identifier or the positions of the mismatching declarations in the diagnostic message?

Actual behavior

incompatible types: `int` and `string` are different type constructors
  expected `int`
    found `string` Millet(5006)
azdavis commented 4 months ago

yeah, this is an old todo:

https://github.com/azdavis/millet/blob/afb85566b1c1aa6f296bf25044eff105f8f06049/crates/sml-statics/src/top_dec/enrich.rs#L3

it's definitely possible in common cases like this, it would just require us to be better about knowing what Idx to emit errors onto.

going to mark this as a feature request since it's not really a bug - the feature as of now works, just suboptimally.