CFG: Handle ensure blocks without body/rescues

This commit is contained in:
Tom Hvitved
2020-12-15 13:44:41 +01:00
parent 489b406e2a
commit 16c25f2a4c
2 changed files with 27 additions and 2 deletions

View File

@@ -1101,12 +1101,26 @@ module Trees {
.lastEnsure(last, nec.getAnInnerCompatibleCompletion(), nec.getOuterCompletion(),
nec.getNestLevel())
)
or
not exists(this.getBodyChild(_, _)) and
not exists(this.getRescue(_)) and
this.lastEnsure0(last, c)
}
final override predicate succ(AstNode pred, AstNode succ, Completion c) {
pred = this and
first(this.getBodyChild(0, _), succ) and
c instanceof SimpleCompletion
c instanceof SimpleCompletion and
(
first(this.getBodyChild(0, _), succ)
or
not exists(this.getBodyChild(_, _)) and
(
first(this.getRescue(0), succ)
or
not exists(this.getRescue(_)) and
first(this.getEnsure(), succ)
)
)
or
// Normal left-to-right evaluation in the body
exists(int i |