-
-
Notifications
You must be signed in to change notification settings - Fork 48
Description
When doing subtyping (initial declaration, assigning, passing argument as parameter, return type etc) the returned result is a SubTypeResult. The subtyping logic (in types/subtyping.rs
) currently collects some of the reasons for mismatches when doing the checking and stores this as a NonEqualityReason.
However this reason is thrown away in many places and does not make it to diagnostics. This can be shown by running rg "SubTypeResult::IsNotSubType\(_"
.
It would be better to pass this via a field to many of the diagnostics. For example here
ezno/checker/src/context/mod.rs
Lines 1115 to 1120 in 5191329
DoesNotMeetConstraint { | |
variable_type: TypeStringRepresentation, | |
variable_site: SpanWithSource, | |
value_type: TypeStringRepresentation, | |
value_site: SpanWithSource, | |
}, |
There should be something like mismatch: MismatchExplanation
. This can be turned into a user readable explanation of why the type error happened. This can be surfaced via adding labels in the Diagnostic::PositionWithAdditionalLabels
.
The
TypeStringRepresentation
enum was designed to cover this, but I don't think it quite fits into this structure.