The code for type checking `seq.nth` was trying to retrieve the sequence
element type before ensuring that the type of the first argument was a
sequence, which lead to assertion failures. This commit reorders the
checks to avoid this issue.
bool check)
{
TypeNode t = n[0].getType(check);
+ if (check && !t.isSequence())
+ {
+ throw TypeCheckingExceptionPrivate(n, "expecting a sequence in nth");
+ }
+
TypeNode t1 = t.getSequenceElementType();
if (check)
{
- if (!t.isSequence())
- {
- throw TypeCheckingExceptionPrivate(n, "expecting a sequence in nth");
- }
TypeNode t2 = n[1].getType(check);
if (!t2.isInteger())
{
regress0/seq/seq-ex5.smt2
regress0/seq/seq-expand-defs.smt2
regress0/seq/seq-nemp.smt2
+ regress0/seq/seq-nth-type-check.smt2
regress0/seq/seq-nth-uf-z.smt2
regress0/seq/seq-nth-uf.smt2
regress0/seq/seq-nth-undef-unsat.smt2
--- /dev/null
+; DISABLE-TESTER: dump
+; EXPECT: expecting a sequence
+; SCRUBBER: grep -o "expecting a sequence"
+; EXIT: 1
+(set-logic QF_SLIA)
+(declare-const i Int)
+(assert (= i (seq.nth 0 i)))
+(check-sat)