lang: If expression was missing two invariants
I forgot to ensure that the type of the final expression matched the type of each of the branches. It's rare, but possible for this to occur. Luckily, this never would have caused a panic, because the func engine would have caught the issue anyways, but it's still better we catch it here first!
This commit is contained in:
@@ -5583,6 +5583,18 @@ func (obj *ExprIf) Unify() ([]interfaces.Invariant, error) {
|
|||||||
}
|
}
|
||||||
invariants = append(invariants, branchesInvar)
|
invariants = append(invariants, branchesInvar)
|
||||||
|
|
||||||
|
// the two branches must match the type of the whole expression
|
||||||
|
thenInvar := &unification.EqualityInvariant{
|
||||||
|
Expr1: obj,
|
||||||
|
Expr2: obj.ThenBranch,
|
||||||
|
}
|
||||||
|
invariants = append(invariants, thenInvar)
|
||||||
|
elseInvar := &unification.EqualityInvariant{
|
||||||
|
Expr1: obj,
|
||||||
|
Expr2: obj.ElseBranch,
|
||||||
|
}
|
||||||
|
invariants = append(invariants, elseInvar)
|
||||||
|
|
||||||
return invariants, nil
|
return invariants, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user