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

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

Open
lue-bird opened this issue Oct 3, 2023 · 1 comment

Comments

@lue-bird
Copy link

lue-bird commented Oct 3, 2023

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.

@github-actions
Copy link

github-actions bot commented Oct 3, 2023

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions in a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

Finally, please be patient with the core team. They are trying their best with limited resources.

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

No branches or pull requests

1 participant