azdavis / millet

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

Unclear where error occurs: `cannot resolve record type containing ...` #17

Closed shwestrick closed 1 year ago

shwestrick commented 1 year ago

Environment

Steps to reproduce

Repo+commit: https://github.com/shwestrick/smlfmt/tree/a14cc23bca3dfd786cd2c7c4d9bdf9c1a14606cd

Added a millet.toml file at the project root:

version = 1
workspace.root = "src/smlfmt.mlb"

Go to src/parse-mlb/ParseAllSMLFromMLB.sml, ln 86: https://github.com/shwestrick/smlfmt/blob/a14cc23bca3dfd786cd2c7c4d9bdf9c1a14606cd/src/parse-mlb/ParseAllSMLFromMLB.sml#L86-L100

Expected behavior

Selectors #dir ctx (line 88) and #parents ctx (line 93) should be individually marked with type errors.

(Note however that MLton does not consider this to be a type error at all, but that's a separate issue. See #18.)

Actual behavior

Millet generates a 5023 error for the entire function.

Screen Shot 2023-01-13 at 1 39 29 PM

The text of the error is cannot resolve record type containing `...`, which is a bit unfortunate in this situation, because it makes it seem like the error is at line 88, where it binds val {result = path, ...}. https://github.com/shwestrick/smlfmt/blob/a14cc23bca3dfd786cd2c7c4d9bdf9c1a14606cd/src/parse-mlb/ParseAllSMLFromMLB.sml#L88

However, the error is actually caused by the selectors #dir ctx and #parents ctx, because Millet is unable to determine the type of ctx. I confirmed that providing a type annotation for the variable ctx makes Millet happy.

azdavis commented 1 year ago

Addressed in 69abb75527a9a3ebe3655633794ee05a97ee2e20