Skip to content

Commit

Permalink
Check assumptions during simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Aug 23, 2024
1 parent e287c4b commit e68a357
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions quint/src/runtime/impl/compilerImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,30 @@ export class CompilerVisitor implements IRVisitor {
return this.errorTracker.runtimeErrors
}

exitAssume(assume: ir.QuintAssume) {
const comp = this.compStack.pop()
if (comp === undefined) {
this.errorTracker.addCompileError(assume.id, 'QNT501', `No expression for ${assume.name} on compStack`)
return
}

const result = comp.eval()
if (result.isLeft()) {
this.errorTracker.addRuntimeError(assume.id, result.value)
return
}

const value = result.value.toQuintEx(zerog)
if (value.kind !== 'bool') {
this.errorTracker.addRuntimeError(assume.id, { code: 'QNT509', message: 'Assume must be a boolean expression' })
return
}

if (!value.value) {
this.errorTracker.addRuntimeError(assume.id, { code: 'QNT510', message: 'Assumption failed' })
}
}

exitOpDef(opdef: ir.QuintOpDef) {
// Either a runtime value, or a def, action, etc.
// All of them are compiled to callables, which may have zero parameters.
Expand Down

0 comments on commit e68a357

Please sign in to comment.