Skip to content

Inconsistent types comparisons between records built from extensible records aliases #2094

@rlefevre

Description

@rlefevre

Quick Summary:
There are some inconsistencies when comparing records types and records types built from extensible record aliases.

SSCCE

module Bug exposing (x, y, z)

import Html exposing (Html)


type alias Named a = { a | name : String }


x : Named { name : String }
x = { name = "" }


y : Named {}
y = { name = "" }


z : { name : String }
z = { name = "" }

Then in elm repl:

> import Bug exposing (..)

> x == z
True : Bool

> y == z
True : Bool

> x == y
-- TYPE MISMATCH ---------------------------------------------------------- REPL

I need both sides of (==) to be the same type:

4|   x == y
     ^^^^^^
The left side of (==) is:

    Named { name : String }

But the right side is:

    Named {}

Different types can never be equal though! Which side is messed up?
  • Elm: 0.19.1
  • Browser: Any
  • Operating System: Any

Additional Details

Related to #2071.

Thank you to @jacobkoling for reporting the issue on Discourse:
https://discourse.elm-lang.org/t/compiler-trips-up-on-extensible-records/5623

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