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

Misleading error message when trying to use tuple type alias as constructor #238

Open adius opened 7 years ago

adius commented 7 years ago

If one tries to use tuple aliases as constructor functions the error message is not helpful.

module Main exposing (..)

type alias PersonRecord =
    { name : String
    , age : Int
    }

recordTest = PersonRecord "John" 32

type alias PersonTuple = ( String, Int )

tupleTest = PersonTuple "John" 32

The error message is Cannot find variable PersonTuple

The thinking then might go: "I just defined PersonTuple two lines above. How can it not be found?" And one might try all kind of strange things to define it differently, importing it and so on.

A live version of this code can be found here: https://ellie-app.com/4dYpWwpgyLTa1/0

Erudition commented 6 years ago

It's even more general than that. type alias Momento = Int or even type Momento = Int declared just before saying box = Momento 345 Give Cannot find variable Momento and nothing else.