Skip to content

Commit 0340510

Browse files
author
Martin Blicha
committed
[SMTChecker] correct handling of FixedBytes constants initialized with string literal
1 parent be56477 commit 0340510

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

Changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Compiler Features:
77

88

99
Bugfixes:
10+
* SMTChecker: Fix internal error on ``FixedBytes`` constant initialized with string literal.
1011
* SMTChecker: Fix internal error on pushing to ``string`` casted to ``bytes``.
11-
1212
AST Changes:
1313

1414

libsmtutil/SolverInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ class Expression
260260
}
261261
friend Expression operator==(Expression _a, Expression _b)
262262
{
263+
smtAssert(_a.sort->kind == _b.sort->kind, "Trying to create an 'equal' expression with different sorts");
263264
return Expression("=", std::move(_a), std::move(_b), Kind::Bool);
264265
}
265266
friend Expression operator!=(Expression _a, Expression _b)

libsolidity/formal/SMTEncoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ void SMTEncoder::endVisit(Identifier const& _identifier)
940940
{
941941
solAssert(decl->value(), "");
942942
decl->value()->accept(*this);
943-
defineExpr(_identifier, expr(*decl->value()));
943+
defineExpr(_identifier, expr(*decl->value(), _identifier.annotation().type));
944944
}
945945
}
946946
else
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pragma experimental SMTChecker;
2+
3+
contract MockContract {
4+
bytes4 public constant SENTINEL_ANY_MOCKS = hex"01";
5+
mapping(bytes4 => bytes4) methodIdMocks;
6+
7+
constructor() {
8+
methodIdMocks[SENTINEL_ANY_MOCKS] = 0;
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pragma experimental SMTChecker;
2+
3+
contract MockContract {
4+
bytes4 public constant SENTINEL_ANY_MOCKS = hex"01";
5+
6+
constructor() {
7+
assert(SENTINEL_ANY_MOCKS >= 0);
8+
}
9+
}

0 commit comments

Comments
 (0)