lang: unification: Catch possible rare bug

When adding some likely incorrect invariants (while testing code) we hit
this panic. While it should not occur, it's probably better to catch it.
This commit is contained in:
James Shubin
2023-08-15 15:32:48 -04:00
parent 33366469a3
commit 0946e860f1

View File

@@ -133,6 +133,10 @@ func (obj *Unifier) Unify() error {
// solver has found a solution, apply it... // solver has found a solution, apply it...
// we're modifying the AST, so code can't error now... // we're modifying the AST, so code can't error now...
for _, x := range solved.Solutions { for _, x := range solved.Solutions {
if x.Expr == nil {
// programming error ?
return fmt.Errorf("unexpected invalid solution at: %p", x)
}
if obj.Debug { if obj.Debug {
obj.Logf("solution: %p => %+v\t(%+v)", x.Expr, x.Type, x.Expr.String()) obj.Logf("solution: %p => %+v\t(%+v)", x.Expr, x.Type, x.Expr.String())
} }