elm / error-message-catalog

A catalog of broken Elm programs / data to improve error messages
BSD 3-Clause "New" or "Revised" License
174 stars 17 forks source link

Missing code location for unknown import #310

Open lydell opened 4 years ago

lydell commented 4 years ago

SSCCE:

module Main exposing (..)

import Missing

x = 1

Error:

-- UNKNOWN IMPORT ------------------------------------------------- src/Main.elm

The Main module has a bad import:

    import Missing

I cannot find that module! Is there a typo in the module name?

The "source-directories" field of your elm.json tells me to only look in the src
directory, but it is not there. Maybe it is in a package that is not installed
yet?

It’s nice that it shows me which import is causing problems, but unlike most other error messages it does not show the line number! I’d expect something more like this:

-- UNKNOWN IMPORT ------------------------------------------------- src/Main.elm

The Main module has a bad import:

3| import Missing
          ^^^^^^^

I cannot find that module! Is there a typo in the module name?

The "source-directories" field of your elm.json tells me to only look in the src
directory, but it is not there. Maybe it is in a package that is not installed
yet?

That would be more consistent, but most importantly it would allow the language server to underline the bad import rather than showing a generic error at the start of the file. See https://github.com/elm-tooling/elm-language-client-vscode/issues/41