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:
@@ -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())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user