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

Bug in compiler message with Url.Parser.Query's #295

Closed harrysarson closed 5 years ago

harrysarson commented 5 years ago

Ellie: https://ellie-app.com/5XXvfxwZ2Pya1

module Main exposing (..)

import Url
import Url.Parser exposing ((<?>))
import Url.Parser.Query

type UrlThings
    = Input String
    | Town String
    | Empty

parser : Url.Parser.Parser (Maybe UrlThings -> a) a
parser =
    (Url.Parser.oneOf [ Url.Parser.top, Url.Parser.s "welsh-whacker" ]
        <?> (Url.Parser.Query.string "input" |> Url.Parser.Query.map (Maybe.map Input))
        <?> (Url.Parser.Query.string "town" |> Url.Parser.Query.map (Maybe.map Town))
        )
Something is off with the body of the `parser` definition:

15|>    (Url.Parser.oneOf [ Url.Parser.top, Url.Parser.s "welsh-whacker" ]
16|>        <?> (Url.Parser.Query.string "input" |> Url.Parser.Query.map (Maybe.map Input))
17|>        <?> (Url.Parser.Query.string "town" |> Url.Parser.Query.map (Maybe.map Town))

The body is:

    Url.Parser.Parser (Maybe UrlThings -> a) a

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

    Url.Parser.Parser (Maybe UrlThings -> a) a
evancz commented 5 years ago

It looks like the fix in https://github.com/elm/compiler/commit/a5febad184588ae79b404d22a020020408580041#diff-82d62175c52da5d84448be854f237b66 gets the type error in order again. On my development build I am seeing:

-- TYPE MISMATCH ------------------------------------------------------ temp.elm

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

15|>    (Url.Parser.oneOf [ Url.Parser.top, Url.Parser.s "welsh-whacker" ]
16|>        <?> (Url.Parser.Query.string "input" |> Url.Parser.Query.map (Maybe.map Input))
17|>        <?> (Url.Parser.Query.string "town" |> Url.Parser.Query.map (Maybe.map Town))

The body is:

    Url.Parser.Parser (Maybe UrlThings -> Maybe UrlThings -> a) a

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

    Url.Parser.Parser (Maybe UrlThings -> a) a

Hint: It looks like it takes too many arguments. I see 1 extra.

The Hint is not quite right, but the types no longer have the bug. The fix should become available once Elm 0.19.1 is released! Thank you for reporting this!