Skip to content

Commit 1ed273b

Browse files
committed
Convert "U_OF_UNIT" from Apalache to the empty tuple
1 parent f7b38df commit 1ed273b

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

quint/src/itf.ts

+6
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ export function ofItf(itf: ItfTrace): QuintEx[] {
189189
if (typeof value === 'boolean') {
190190
return { id, kind: 'bool', value }
191191
} else if (typeof value === 'string') {
192+
if (value === 'U_OF_UNIT') {
193+
// Apalache converts empty tuples to its unit value, "U_OF_UNIT".
194+
// We need to convert it back to Quint's unit value, the empty tuple.
195+
return { id, kind: 'app', opcode: 'Tup', args: [] }
196+
}
197+
192198
return { id, kind: 'str', value }
193199
} else if (isBigint(value)) {
194200
// this is the standard way of encoding an integer in ITF.

quint/test/itf.test.ts

+24
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,28 @@ describe('toItf', () => {
8888
`round trip conversion of trace failed`
8989
)
9090
})
91+
92+
it('converts unit type from Apalache', () => {
93+
const text = '{ a: () }'
94+
95+
const trace = [buildExpression(text)]
96+
const vars = ['a']
97+
const itfTrace = {
98+
vars: vars,
99+
states: [
100+
{
101+
'#meta': {
102+
index: 0,
103+
},
104+
a: 'U_OF_UNIT',
105+
},
106+
],
107+
}
108+
109+
const roundTripTrace = ofItf(itfTrace)
110+
assert(
111+
zip(roundTripTrace, trace).every(([a, b]) => quintExAreEqual(a, b)),
112+
`round trip conversion of trace failed`
113+
)
114+
})
91115
})

0 commit comments

Comments
 (0)