Skip to content
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

Wrong type annotation on the generated binding in case of type shadowing #104

Open
miniBill opened this issue Dec 2, 2024 · 1 comment · May be fixed by #105
Open

Wrong type annotation on the generated binding in case of type shadowing #104

miniBill opened this issue Dec 2, 2024 · 1 comment · May be fixed by #105

Comments

@miniBill
Copy link
Contributor

miniBill commented Dec 2, 2024

module Foo exposing (a)

import Imported exposing (Foo(..))


type alias Foo a =
    Imported.Foo a


a : Foo Int
a =
    Debug.todo ""

Should codegen

module Gen.Foo exposing ( moduleName_, a, values_ )

{-|
# Generated bindings for Foo

@docs moduleName_, a, values_
-}


import Elm
import Elm.Annotation as Type


{-| The name of this module. -}
moduleName_ : List String
moduleName_ =
    [ "Foo" ]


{-| a: Foo.Foo Int -}
a : Elm.Expression
a =
    Elm.value
        { importFrom = [ "Foo" ]
        , name = "a"
        , annotation = Just (Type.namedWith [ "Foo" ] "Foo" [ Type.int ])
        }


values_ : { a : Elm.Expression }
values_ =
    { a =
        Elm.value
            { importFrom = [ "Foo" ]
            , name = "a"
            , annotation = Just (Type.namedWith [ "Foo" ] "Foo" [ Type.int ])
            }
    }

But instead it generates:

module Gen.Foo exposing ( moduleName_, a, values_ )

{-|
# Generated bindings for Foo

@docs moduleName_, a, values_
-}


import Elm
import Elm.Annotation as Type


{-| The name of this module. -}
moduleName_ : List String
moduleName_ =
    [ "Foo" ]


{-| a: Imported.Foo Int -}
a : Elm.Expression
a =
    Elm.value
        { importFrom = [ "Foo" ]
        , name = "a"
        , annotation = Just (Type.namedWith [ "Imported" ] "Foo" [ Type.int ])
        }


values_ : { a : Elm.Expression }
values_ =
    { a =
        Elm.value
            { importFrom = [ "Foo" ]
            , name = "a"
            , annotation =
                Just (Type.namedWith [ "Imported" ] "Foo" [ Type.int ])
            }
    }

The error doesn't happen if we don't import Foo from Imported

@miniBill
Copy link
Contributor Author

miniBill commented Dec 2, 2024

This is the cause of dillonkearns/elm-pages#501

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant