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

Duplicate fields with record extensions #1550

Open
martinmodrak opened this issue Jan 5, 2017 · 1 comment
Open

Duplicate fields with record extensions #1550

martinmodrak opened this issue Jan 5, 2017 · 1 comment

Comments

@martinmodrak
Copy link

martinmodrak commented Jan 5, 2017

This is related to #1344 and #1323, but as the following bug is not fixed in a build made after those bugs were closed in #1374, I think it is relevant (tested against build taken from https://groups.google.com/forum/#!topic/elm-dev/c_BDwK5UXFs)

The point is that I can make duplicate fields by using record extension. The following code compiles without errors:

type alias A a =
  {a | x : Int}

type alias B =
  {x : String}

test : A B
test = 
  { x = 1}

In all cases, the actual type is taken from the outermost type (A here). I think this should be a compile-time error, for the same reasons that field duplication is forbidden in other contexts.

Furthermore, having fields of the same name is also the only case that breaks a simple assumption about type aliases with record extension:

type alias T a =
  {a | .... }

type alias U a =
 {a | ... }

Now, T (U a) and U (T a) are exactly the same type for all a (unless there are duplicate field names).

@process-bot
Copy link

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

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

No branches or pull requests

3 participants