Skip to content

Compiler hangs on infinite type in badly written foldl lambda #1700

Open
@drewwestphal

Description

@drewwestphal

Referencing #1240 here as many similar (largely closed) issues reference it. Noted that @evancz suggested creating new issues in most cases, so I am doing so rather than piling on there--hope that is desired.

This causes the compiler to hang on 0.18.0 on a mac. (Also hangs elm reactor.)

listUnique lst =
    List.foldr
        (\elem uniq ->
            if List.member elem uniq then
                uniq
            else
                uniq :: elem
        )
        []
        lst

By breaking out the lambda into its own function (suggested on the elm slack), the compiler detects and errors on an infinite type (see here for that example)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions