Tweak liveness analysis for if-else chains

This commit is contained in:
Nigel Tao committed 2022-01-25 19:40:22 +11:00
1 parent 14f5859311
commit 97eb1290f5
3 files changed
+12 -13

No files matched your search

+5
View File
@@ -121,6 +121,11 @@ func (q *checker) tcheckStatement(n *a.Node) error {
}
case a.KIf:
for n := n.AsIf(); n != nil; n = n.ElseIf() {
if (n.ElseIf() != nil) && (len(n.BodyIfFalse()) > 0) {
return fmt.Errorf("check: if has an else-if and an else-not-if")
}
}
for n := n.AsIf(); n != nil; n = n.ElseIf() {
cond := n.Condition()
if cond.Effect() != 0 {