Open zerbina opened 3 months ago
It's not yet clear what distinct object
in a type definition should mean. My preference is that it should mean the same as in a usage context (i.e., type-class), whereas @alaviss argues that it should be a shorthand for object
type definition + distinct
type construction (similar to how ref object
and ptr object
work).
The discussion so far can be found here.
Example
Actual Output
The compiler crashes:
Expected Output
A proper compiler error about
distinct object
not being a valid type.Additional Information
The crash is due to the
object
part resulting in an incompletetyObject
type instance. Among other things, it's missing a symbol, violating the invariant oftyObject
always having a symbol attached, thus crashing the compiler once the symbol is attempted to be accessed.There are two problems here:
object
as it's used here doesn't construct atyObject
type, but instead names the built-inobject
type-class (i.e.,(BuiltInTypeClass (Object))
). The logic insemtypes.semObjectNode
doesn't handle this properly.distinct T
whereT
is a type-class is only valid in a routine parameter or generic parameter position, but there's nothing enforcing this.References
The issue was discovered with the cps test suite and reported by @alaviss on Matrix.