Skip to content

record extended with additional field not accepted as extensible record with record with same fields #2312

Open
@lue-bird

Description

@lue-bird

In this example of correct elm code

type alias Base other =
    { other | base : () }

type alias Specific other =
    Base { other | extra : () }

extra : Base (Specific other) -> ()
extra specificArgument =
    specificArgument.extra

specific : Base { extra : () }
specific =
    { base = ()
    , extra = ()
    }

specificExtra =
    extra specific

elm complains

-- TYPE MISMATCH -------------------------------------------------- src/Bug.elm

The 1st argument to `extra` is not what I expect:

25|     extra specific
              ^^^^^^^^
This `specific` value is a:

    Base { extra : () }

But `extra` needs the 1st argument to be:

    Base (Specific other)

Hint: Seems like a record field typo. Maybe base should be extra?

Hint: Can more type annotations be added? Type annotations always help me give
more specific messages, and I think they could help a lot in this case!

Any other combination of types (and no types) for extra and specific I've tried do not lead to this problem.

Additional Details

Popped up while refactoring the type properties in https://github.com/jfmengels/elm-review-simplify

#2298 might be related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions