Skip to content

Duplicate fields with record extensions #1550

Open
@martinmodrak

Description

@martinmodrak

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions