Skip to content

Compiler hangs and uses more and more memory on type error. #2214

Open
@ajmcmiddlin

Description

@ajmcmiddlin

Quick Summary: Compiler hangs and uses more and more memory on type error.

SSCCE

module Main exposing (..)

type alias Lens a b =
    { get : a -> b
    , set : b -> a -> a
    }

type alias Foo =
    { n : Int }

fooN : Lens Foo Int
fooN =
    Lens .n (\foo n -> { foo | n = n })
  • Elm: 0.19.1
  • Browser: NA
  • Operating System: Linux (NixOS 20.09 with kernel 5.4.119)

Additional Details

When I run elm make src/Main.elm the command never returns, and continues to use more and more memory until I kill the process.

The issue is with fooN, as the anonymous function used to define set has its parameters around the wrong way. If we change the definition to fooN = Lens .n (\n foo -> {foo | n = n}) then it compiles without error.

Additionally, if we simplify the Lens type definition to only include set, the compiler produces a type error and doesn't hang.

I originally encountered this using elm-monocle but have inlined the Lens definition to reproduce.

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