New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List.sortWith given invalid order function causes compiler to hang #852

Closed
mordrax opened this Issue Apr 8, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@mordrax

mordrax commented Apr 8, 2017

List.sortWith (Tuple.second >> (>)) [("a",4),("d",7),("b",6)]

causes my 0.18 compiler to hang, cpu and memory goes through the roof.

I fixed this by realising that the order function is completely wrong and that I should have gone with

List.sortBy Tuple.second [("a", 4), ... ]

However, the usually friendly compiler got very confused and never returned.

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Apr 8, 2017

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Apr 8, 2017

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Jul 10, 2017

Member

This is "infinite types can hang rather than give a nice error" problem. The upcoming error is like this:

-- INFINITE TYPE ------------------ /Users/evan/Documents/pkgs/core/src/List.elm

I am inferring a weird self-referential type for the 1st argument to function
`sortWith`:

57|   sortWith (Tuple.second >> (>)) [("a",4),("d",7),("b",6)]
                ^^^^^^^^^^^^^^^^^^^
Here is my best effort at writing down the type. You will see ∞ for parts of the
type that repeat something already printed out infinitely.

    ( comparable, ∞ ) -> ( comparable, ∞ ) -> Order

Usually staring at the type is not so helpful in these cases, so definitely read
the debugging hints for ideas on how to figure this out:
<https://github.com/elm-lang/elm-compiler/blob/0.19.0/hints/infinite-type.md>

Probably could be improved, but that is for https://github.com/elm-lang/error-message-catalog

Member

evancz commented Jul 10, 2017

This is "infinite types can hang rather than give a nice error" problem. The upcoming error is like this:

-- INFINITE TYPE ------------------ /Users/evan/Documents/pkgs/core/src/List.elm

I am inferring a weird self-referential type for the 1st argument to function
`sortWith`:

57|   sortWith (Tuple.second >> (>)) [("a",4),("d",7),("b",6)]
                ^^^^^^^^^^^^^^^^^^^
Here is my best effort at writing down the type. You will see ∞ for parts of the
type that repeat something already printed out infinitely.

    ( comparable, ∞ ) -> ( comparable, ∞ ) -> Order

Usually staring at the type is not so helpful in these cases, so definitely read
the debugging hints for ideas on how to figure this out:
<https://github.com/elm-lang/elm-compiler/blob/0.19.0/hints/infinite-type.md>

Probably could be improved, but that is for https://github.com/elm-lang/error-message-catalog

@evancz evancz closed this Jul 10, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment