mdgriffith / elm-codegen

https://package.elm-lang.org/packages/mdgriffith/elm-codegen/latest/
BSD 3-Clause "New" or "Revised" License
138 stars 16 forks source link

Modules refrenced in tuple deconstructions in let statements are not imported #66

Closed Cindiary closed 10 months ago

Cindiary commented 1 year ago

With the following code

Elm.file [ "Test" ]
Elm.file [ "Test" ]
[ Elm.Let.letIn ( \( _, value ) -> value )
  |> Elm.Let.tuple "_" "value"
      ( Elm.tuple
        Elm.unit
        ( [ Elm.int 1, Elm.int 2, Elm.int 3 ]
          |> Gen.Array.fromList
          |> Gen.Array.get 1
        )
      )
  |> Elm.Let.toExpression
  |> Elm.declaration "test"
]

The following file is generated

module Test exposing (..)

test : Maybe a
test =
    let
        ( _, value ) =
            ( (), Array.get 1 (Array.fromList [ 1, 2, 3 ]) )
    in
    value

Which is missing an import statement for the Array module and does not compile

mdgriffith commented 10 months ago

This should be fixed in the latest release! Thank you!