elm / error-message-catalog

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

"Cannot find variable `X.T`. No module called X has been imported." when X has been imported but not exposing type correctly #215

Open stoft opened 7 years ago

stoft commented 7 years ago

I get the following error even though I have imported SubTypes:

Detected errors in 1 module.
-- NAMING ERROR ------------------------------------------------------- Main.elm

Cannot find variable `SubTypes.MyType`.

15|             SubType SubTypes.MyType
                        ^^^^^^^^^^^^^^^
No module called `SubTypes` has been imported. 

The actual error is that the SubTypes module is not exposing its type correctly: module SubTypes exposing (Type) when it should be module SubTypes exposing (Type(..)). A more correct error message would be that SubTypes does not expose MyType.

SSCCE:

module SubTypes exposing (Type)

type Type
    = MyType
module Main exposing (main)

import Html
import SubTypes

type SuperType
    = NoOp
    | SubType SubTypes.Type

main =
    let
        t =
            SubType SubTypes.MyType
    in
        Html.text "MyType found!"
isti115 commented 6 years ago

This was real confusing, because it happened to me while using an "as" alias in the import and thought that it was the cause of the bug, but I'm glad I found this issue before reporting it as a new one. weird_elm_error