millet icon indicating copy to clipboard operation
millet copied to clipboard

Signature / structure type mismatch location

Open vqns opened this issue 1 year ago • 1 comments

Environment

  • Millet version: a05263d4

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)

vqns avatar May 02 '24 12:05 vqns

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.

azdavis avatar May 04 '24 20:05 azdavis