This PR fixes #5448. SynthFunCommand::toStream used to call d_grammar->resolve even when d_grammar is a nullptr. This PR fixes the issue and modifies the signature of Printer::toStreamCmdSynthFun to make it clear that grammar is an optional argument.
const std::vector<Node>& vars,
TypeNode range,
bool isInv,
- TypeNode sygusType) const;
+ TypeNode sygusType = TypeNode::null()) const;
/** Print constraint command */
virtual void toStreamCmdConstraint(std::ostream& out, Node n) const;
}
out << '\n';
// print grammar, if any
- if (sygusType != TypeNode::null())
+ if (!sygusType.isNull())
{
toStreamSygusGrammar(out, sygusType);
}
TypeNode type) const override;
/** Print synth-fun command */
- void toStreamCmdSynthFun(std::ostream& out,
- const std::string& sym,
- const std::vector<Node>& vars,
- TypeNode range,
- bool isInv,
- TypeNode sygusType) const override;
+ void toStreamCmdSynthFun(
+ std::ostream& out,
+ const std::string& sym,
+ const std::vector<Node>& vars,
+ TypeNode range,
+ bool isInv,
+ TypeNode sygusType = TypeNode::null()) const override;
/** Print constraint command */
void toStreamCmdConstraint(std::ostream& out, Node n) const override;
nodeVars,
d_sort.getTypeNode(),
d_isInv,
- d_grammar->resolve().getTypeNode());
+ d_grammar == nullptr ? TypeNode::null()
+ : d_grammar->resolve().getTypeNode());
}
/* -------------------------------------------------------------------------- */
regress0/sygus/issue3645-grammar-sets.smt2
regress0/sygus/issue4383-cache-fv-id.sy
regress0/sygus/issue4790-dtd.sy
+ regress0/sygus/issue5512-vvv.sy
regress0/sygus/let-ringer.sy
regress0/sygus/let-simp.sy
regress0/sygus/no-logic.sy
--- /dev/null
+; COMMAND-LINE: -vvv --sygus-out=status --check-synth-sol --check-abducts
+; SCRUBBER: sed -e 's/.*//g'
+; EXIT: 0
+
+; This regression ensures that printing Sygus commands with option -vvv does not
+; crash CVC4
+
+(set-logic UF)
+(declare-var x Bool)
+(synth-fun f ((x Bool)) Bool ((Start Bool)) ((Start Bool (true))))
+(synth-inv inv-f ((x Bool)))
+(define-fun pre-f ((x Bool)) Bool true)
+(define-fun trans-f ((x Bool) (x! Bool)) Bool true)
+(define-fun post-f ((x Bool)) Bool true)
+(inv-constraint inv-f pre-f trans-f post-f)
+(constraint true)
+(check-synth)