Elm Exactly
Results / elm /

CompilerIssue1822AliasOfRecordAliasConstructorTest

Tags:elm19-bugelm-spec-contradicts

XFAIL Expected to fail: the book gives a constructor only to an alias of a record type, so Y is no constructor and the program is rejected

elm-0.19.1 failelm-0.19.2 failelm-0.19.3 faillamdera-1.5.0 fail

Issue: elm/compiler#1822

An alias of a record type alias has no record constructor.

<https://github.com/elm/compiler/issues/1822>

`Y` is an alias of the record alias `X`, so `Y` should construct an `X` like `X` does. Elm 0.19.1
reports "I cannot find a `Y` variant".

A Standard Definition of Elm? does not accept this as a bug. Only a record alias, an alias whose
type is a record type expression, declares a constructor of its name (restriction
modules-constructors-distinct). `type alias Y = X` aliases an alias, not a record type, so `Y` is
no constructor, and the program, which uses it as one, is rejected.
<https://elm-test-suite.netlify.app/standard/restrictions/modules-constructors-distinct>

Results

elm-0.19.1

fail
compile failed (exit 1):
Compiling ...-- NAMING ERROR ----- src/CompilerIssue1822AliasOfRecordAliasConstructorTest.elm

I cannot find a `Y` variant:

36|             Debug.log "y" (Y "a" "b")
                               ^
These names seem close though:

    X
    EQ
    GT
    LT

Hint: Read <https://elm-lang.org/0.19.1/imports> to see how `import`
declarations work in Elm.

Detected problems in 1 module.

elm-0.19.2

fail
compile failed (exit 1):
Dependencies ready!
Compiling ...-- NAMING ERROR ----- src/CompilerIssue1822AliasOfRecordAliasConstructorTest.elm

I cannot find a `Y` variant:

36|             Debug.log "y" (Y "a" "b")
                               ^
These names seem close though:

    X
    EQ
    GT
    LT

Hint: Read <https://elm-lang.org/0.19.2/imports> to see how `import`
declarations work in Elm.

Detected problems in 1 module.

elm-0.19.3

fail
compile failed (exit 1):
Compiling ...-- NAMING ERROR ----- src/CompilerIssue1822AliasOfRecordAliasConstructorTest.elm

I cannot find a `Y` variant:

36|             Debug.log "y" (Y "a" "b")
                               ^
These names seem close though:

    X
    EQ
    GT
    LT

Hint: Read <https://elm-lang.org/0.19.3/imports> to see how `import`
declarations work in Elm.

Detected problems in 1 module.

lamdera-1.5.0

fail
compile failed (exit 1):
Detected problems in 1 module.
-- NAMING ERROR ----- src/CompilerIssue1822AliasOfRecordAliasConstructorTest.elm

I cannot find a `Y` variant:

36|             Debug.log "y" (Y "a" "b")
                               ^
These names seem close though:

    X
    EQ
    GT
    LT

Hint: Read <https://elm-lang.org/0.19.3/imports> to see how `import`
declarations work in Elm.

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm/CompilerIssue1822AliasOfRecordAliasConstructorTest] in its title.

Source

The -- CHECK: lines give the expected output.

module CompilerIssue1822AliasOfRecordAliasConstructorTest exposing (..)
{-| An alias of a record type alias has no record constructor.
<https://github.com/elm/compiler/issues/1822>
`Y` is an alias of the record alias `X`, so `Y` should construct an `X` like `X` does. Elm 0.19.1
reports "I cannot find a `Y` variant".
A Standard Definition of Elm? does not accept this as a bug. Only a record alias, an alias whose
type is a record type expression, declares a constructor of its name (restriction
modules-constructors-distinct). `type alias Y = X` aliases an alias, not a record type, so `Y` is
no constructor, and the program, which uses it as one, is rejected.
<https://elm-test-suite.netlify.app/standard/restrictions/modules-constructors-distinct>
-}
-- TAGS: elm19-bug, elm-spec-contradicts
-- XFAIL: the book gives a constructor only to an alias of a record type, so Y is no constructor and the program is rejected
-- CHECK: y: { a = "a", b = "b" }
import Html exposing (text)
type alias X =
{ a : String, b : String }
type alias Y =
X
main =
let
_ =
Debug.log "y" (Y "a" "b")
in
text "done"