Add type unification boundaries to improve diagnostic messages #33
Labels
No labels
blocked
blocker
bug
c
codegen
dependencies
discussion
documentation
duplicate
enhancement
good first issue
help wanted
in progress
invalid
javascript
lexer/parser
llvm
macroexpander
performance
priority:high
priority:low
priority:normal
question
triage
typechecker
webassembly
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: samvv/bolt#33
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The problem we're facing is that error messages often do not explain exactly what made the error occur. A small improvement would be to pick an arbitrary expression from one side of the equation, pick one from the other, and print these nodes out.
One thing we could do is to keep a cyclic list on each type that grows with each successful join with another type. That way, the cyclic list would eventually contain all the types that are the same. If we then would add a guard that this list may only grow when encountering a type that isn't 'the one'
TCon
, we would end up with partial lists that contain only the subset of the program that were inferred as equal but not necessarily as specifically theInt
or theBool
.Next, we need a mechanism where an
Int
from a constant expression1
is not equal to anInt
from e.g. a type reference. This requires the introduction of an intermediate type. In the simplest case, we just clone aTCon
and assign a new node to it. Some flags would need to ensure that thisTCon
is different from the globalTCon
types we wish to avoid.If we had such lists, then an unification error could retrieve the two conflicting cycles by inspecting the two original types that the solver requested to be unified.