elm / compiler

Compiler for Elm, a functional language for reliable webapps.
https://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
7.52k stars 661 forks source link

Identity type alias causes problems #2298

Open Heimdell opened 1 year ago

Heimdell commented 1 year ago

Quick Summary:

I entered an identity type alias, but elm refuses to unify LHS and RHS of the type alias later.

SSCCE

module Both.Msg exposing (..)

type alias Msg a = a

make : a -> Msg a
make = identity

=>

Something is off with the body of the `make` definition:

6| make = identity
          ^^^^^^^^
This `identity` value is a:

    a -> a

But the type annotation on `make` says it should be:

    a -> Msg a

Additional Details

Msg a and a, for all a, by definition, have to be the same type. Yet, Elm refuses to acknowledge that anything a is also Msg a.

Funny thing, the code

module Both.Msg exposing (..)

type alias Msg a = a

make : Msg a -> a
make = identity

compiles just fine.

github-actions[bot] commented 1 year ago

Thanks for reporting this! To set expectations:

Finally, please be patient with the core team. They are trying their best with limited resources.

Heimdell commented 1 year ago

Duplicate of https://github.com/elm/compiler/issues/2252