Skip to content

Commit c7db606

Browse files
authored
Print a warning about function parameter names being used instead of values in SMTChecker (#14832)
1 parent 1183284 commit c7db606

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

Diff for: Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Language Features:
2323
Compiler Features:
2424
* EVM: Support for the EVM Version "Cancun".
2525
* SMTChecker: Support `bytes.concat` except when string literals are passed as arguments.
26+
* SMTChecker: Print a message that function parameter name was used instead of a concrete value in a counterexample when the concrete value found by the solver is too long to print.
2627
* Standard JSON Interface: Add experimental support to import EVM assembly in the format used by ``--asm-json``.
2728
* TypeChecker: Comparison of internal function pointers now yields a warning, as it can produce unexpected results with the legacy pipeline enabled.
2829

Diff for: libsolidity/formal/Predicate.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,14 @@ std::string Predicate::formatSummaryCall(
316316

317317
auto const& params = fun->parameters();
318318
solAssert(params.size() == functionArgsCex.size(), "");
319+
bool paramNameInsteadOfValue = false;
319320
for (unsigned i = 0; i < params.size(); ++i)
320321
if (params.at(i) && functionArgsCex.at(i))
321322
functionArgs.emplace_back(*functionArgsCex.at(i));
322-
else
323+
else {
324+
paramNameInsteadOfValue = true;
323325
functionArgs.emplace_back(params[i]->name());
326+
}
324327

325328
std::string fName = fun->isConstructor() ? "constructor" :
326329
fun->isFallback() ? "fallback" :
@@ -335,7 +338,11 @@ std::string Predicate::formatSummaryCall(
335338
solAssert(fun->annotation().contract, "");
336339
prefix = fun->annotation().contract->name() + ".";
337340
}
338-
return prefix + fName + "(" + boost::algorithm::join(functionArgs, ", ") + ")" + txModel;
341+
342+
std::string summary = prefix + fName + "(" + boost::algorithm::join(functionArgs, ", ") + ")" + txModel;
343+
if (paramNameInsteadOfValue)
344+
summary += " -- counterexample incomplete; parameter name used instead of value";
345+
return summary;
339346
}
340347

341348
std::vector<std::optional<std::string>> Predicate::summaryStateValues(std::vector<smtutil::Expression> const& _args) const

Diff for: test/libsolidity/smtCheckerTests/types/string_1.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ contract C
66
}
77
// ====
88
// SMTEngine: all
9+
// SMTIgnoreCex: no
910
// ----
10-
// Warning 6328: (77-121): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.f(s1, s2)
11+
// Warning 6328: (77-121): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.f(s1, s2) -- counterexample incomplete; parameter name used instead of value

0 commit comments

Comments
 (0)