You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
note: Incomplete. These are just some findings while experimenting
When a {type used in an extensible record| ... }
is constrained
is inferred to a non-record type
is a non-record argument of a type alias or type
the printed elm error message is interrupted by a haskell error.
Note: #1684 is a meta-issue from 2018 for the lack of kind checking on inference
normal behavior
any: { a | a : () }
any ={ a =()}
Something is off with the body of the any definition:
{ a = () }
^^^^^^^^^^
The body is a record of type:
{ a : () }
But the type annotation on any says it should be:
{ a | a : () }
type argument mismatches
type ExtendedRecord record
=ExtendedRecord{ record | a :()}number:ExtendedRecordnumbernumber =ExtendedRecord{ a =()}unit:ExtendedRecord()unit =ExtendedRecord{ a =()}
also error as expected:
Something is off with the body of the definition:
19| ExtendedRecord { a = () }
^^^^^^^^^^^^^^^^^^^^^^^^^
This ExtendedRecord call produces:
ExtendedRecord {}
But the type annotation says it should be:
ExtendedRec ()
mismatches between record type alias and non-record
type alias ExtendedRecord record ={ record | field :()}number:ExtendedRecordnumbernumber =()unit:ExtendedRecord()unit =()
also error as expected:
Something is off with the body of the definition:
10| ()
^^
The body is a unit value:
()
But the type annotation says it should be:
ExtendedRecord number/()
behavior with constrained variables
number: { number | field : () }
number =()
Something is off with the body of the number definition:
11| ()
^^
The body is a unit value:
elm: Used toErrorType on a type that is not well-formed
CallStack (from HasCallStack):
error, called at compiler/src/Type/Type.hs:541:21 in main:Type.Type
This happens for all constrained variable types (compappend, appendable, comparable, number).
behavior with inferred variables
When using a and { a | field : a } in one function type, calling that function with bad typed arguments leads to elm running into an error trying to produce an error message.
changeNothing:a-> { a | a : a } -> { a | a : a }
changeNothing _ a =
a
breaks =
changeNothing (){}
The code in breaks is incorrect but when elm tries to tell us, it fails with
elm: Used toErrorType on a type that is not well-formed
CallStack (from HasCallStack):
error, called at compiler/src/Type/Type.hs:541:21 in main:Type.Type
a seems to be inferred as a : (), breaking the extensible record type.
behavior with type and type alias
type alias
Problematic is the following:
unit:ExtendedRecord()unit ={}
where the value is any record and the ExtendedRecord argument is constrained, inferred to or any non-record type. This sub-issue is covered in
type ExtendedRecord number =ExtendedRecord{ number | a :()}number:ExtendedRecordnumbernumber =ExtendedRecord()
The 1st argument to ExtendedRecord is not what I expect:
10| ExtendedRecord ()
^^
This argument is a unit value:
elm: Used toErrorType on a type that is not well-formed
CallStack (from HasCallStack):
error, called at compiler/src/Type/Type.hs:541:21 in main:Type.Type
additional details
Elm 0.19.1
Operating System: Ubuntu 20.04.2 LTS
The text was updated successfully, but these errors were encountered:
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.
lue-bird
changed the title
failing to construct an error message when calling a function of a type containing a & { a | field : a }
fails to construct error message when calling a function of a type with a & { a | field : a }
May 8, 2021
lue-bird
changed the title
fails to construct error message when calling a function of a type with a & { a | field : a }
fails to construct error message when calling a function of a type with a & { a | field : a }Jun 27, 2021
lue-bird
changed the title
fails to construct error message when calling a function of a type with a & { a | field : a }
fails to preduce error message when calling a function of a type with a & { a | field : a }Jul 21, 2021
lue-bird
changed the title
fails to preduce error message when calling a function of a type with a & { a | field : a }
fails to preduce error message on certain extended record type alias argument types
Apr 8, 2022
When a
{
type used in an extensible record| ... }
type alias
ortype
the printed elm error message is interrupted by a haskell error.
normal behavior
type
argument mismatchesalso error as expected:
mismatches between record
type alias
and non-recordalso error as expected:
behavior with constrained variables
This happens for all constrained variable types (
compappend
,appendable
,comparable
,number
).behavior with inferred variables
When using
a
and{ a | field : a }
in one function type, calling that function with bad typed arguments leads to elm running into an error trying to produce an error message.The code in
breaks
is incorrect but when elm tries to tell us, it fails witha
seems to be inferred asa : ()
, breaking the extensible record type.behavior with
type
andtype alias
type alias
Problematic is the following:
where the value is any record and the
ExtendedRecord
argument is constrained, inferred to or any non-record type. This sub-issue is covered intype
argumentsadditional details
The text was updated successfully, but these errors were encountered: