Skip to content

Commit

Permalink
Account for predefined set names (#2603)
Browse files Browse the repository at this point in the history
Translate name of predefined Bool set
  • Loading branch information
thpani authored Jun 16, 2023
1 parent ed07563 commit 79900a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tla-io/src/main/scala/at/forsyte/apalache/io/quint/Quint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,19 @@ class Quint(moduleData: QuintOutput) {
case QuintInt(_, i) => Reader(_ => tla.int(i))
case QuintStr(_, s) => Reader(_ => tla.str(s))
case QuintName(id, name) =>
val t = Quint.typeToTlaType(types(id).typ)
Reader { nullaryOpNames =>
if (nullaryOpNames.contains(name)) {
tla.appOp(tla.name(name, OperT1(Seq(), t)))
} else {
tla.name(name, t)
}
name match {
// special case: predefined set BOOLEAN is Bool in Quint
case "Bool" => Reader(_ => tla.booleanSet())
// general case: some other name
case _ =>
val t = Quint.typeToTlaType(types(id).typ)
Reader { nullaryOpNames =>
if (nullaryOpNames.contains(name)) {
tla.appOp(tla.name(name, OperT1(Seq(), t)))
} else {
tla.name(name, t)
}
}
}
case QuintLet(_, binding: QuintDef.QuintOpDef, scope) if binding.qualifier == "nondet" =>
nondetBinding(binding, scope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ class TestQuintEx extends AnyFunSuite {
assert(convert(Q.name) == "n")
}

test("can convert predefined sets") {
assert(convert(Q.nam("Bool", QuintSetT(QuintBoolT()))) == "BOOLEAN")
assert(convert(Q.nam("Int", QuintSetT(QuintIntT()))) == "Int")
assert(convert(Q.nam("Nat", QuintSetT(QuintIntT()))) == "Nat")
}

test("can convert let expression") {
assert(convert(Q.letFooBeTrueIn42) == "LET foo ≜ TRUE IN 42")
}
Expand Down

0 comments on commit 79900a4

Please sign in to comment.