Skip to content

Commit

Permalink
Merge pull request #2782 from informalsystems/2774/catch-nonnondet-oneOf
Browse files Browse the repository at this point in the history
Add case to handle oneOf outside of nondet
  • Loading branch information
Shon Feder authored Nov 24, 2023
2 parents c40dc46 + fc97698 commit b7cd23e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,15 @@ class Quint(quintOutput: QuintOutput) {
val applicationBuilder: Seq[QuintEx] => NullaryOpReader[TBuilderInstruction] = opName match {
// First we check for application of builtin operators

// Illegal builtins
// We expect that these builins will be eliminated in earlier stages
// of the translation (e.g., inside special forms like `nondet`) or
// via rewrites in quint.
case "oneOf" =>
// See https://github.com/informalsystems/apalache/issues/2774
throw new QuintIRParseError(
s"`oneOf` can only occur as the principle operator of a `nondet` declaration: `oneOf` operator with id ${id} applied to ${quintArgs}")

// Booleans
case "eq" => binaryApp(opName, tla.eql)
case "neq" => binaryApp(opName, tla.neql)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,4 +751,10 @@ class TestQuintEx extends AnyFunSuite {
// And if our conversion logic is correct, we can convert this to Apalache's IR:
assert(convert(expr) == """LET polyConst1(x) ≜ 1 IN (polyConst1("s")) + (polyConst1(TRUE))""")
}

test("oneOf operator occuring outside of a nondet binding is an error") {
// See https://github.com/informalsystems/apalache/issues/2774
val err = intercept[QuintIRParseError](convert(Q.oneOfSet))
assert(err.getMessage().contains("`oneOf` can only occur as the principle operator of a `nondet` declaration"))
}
}

0 comments on commit b7cd23e

Please sign in to comment.