[SMTChecker] Fix override tests

This commit is contained in:
Leonardo Alt 2019-11-05 17:55:05 +01:00
parent 23b6a8eb07
commit fc945880d1
8 changed files with 122 additions and 11 deletions

View File

@ -52,6 +52,7 @@ bool SMTEncoder::visit(ContractDefinition const& _contract)
for (auto const& function: resolvedFunctions) for (auto const& function: resolvedFunctions)
if ( if (
function->name() == baseFunction->name() && function->name() == baseFunction->name() &&
function->kind() == baseFunction->kind() &&
FunctionType(*function).asCallableFunction(false)-> FunctionType(*function).asCallableFunction(false)->
hasEqualParameterTypes(*FunctionType(*baseFunction).asCallableFunction(false)) hasEqualParameterTypes(*FunctionType(*baseFunction).asCallableFunction(false))
) )

View File

@ -0,0 +1,27 @@
pragma experimental SMTChecker;
// 2 warnings, fallback and A.g
contract A {
uint x;
fallback () external {
assert(x == 1);
}
function g() public view {
assert(x == 1);
}
}
// 2 warnings, fallback and A.g
contract B is A {
uint y;
fallback () external override {
assert(x == 0);
}
}
// ----
// Warning: (114-128): Assertion violation happens here
// Warning: (163-177): Assertion violation happens here
// Warning: (280-294): Assertion violation happens here
// Warning: (163-177): Assertion violation happens here

View File

@ -0,0 +1,28 @@
pragma experimental SMTChecker;
// 2 warnings, fallback and A.g
contract A {
uint x;
fallback () external {
assert(x == 1);
}
function g() public view {
assert(x == 1);
}
}
// 3 warnings, receive, A.fallback and A.g
contract B is A {
uint y;
receive () external payable {
assert(x == 0);
}
}
// ----
// Warning: (114-128): Assertion violation happens here
// Warning: (163-177): Assertion violation happens here
// Warning: (289-303): Assertion violation happens here
// Warning: (114-128): Assertion violation happens here
// Warning: (163-177): Assertion violation happens here

View File

@ -14,12 +14,12 @@ contract A {
// 2 warnings, B.f and A.g // 2 warnings, B.f and A.g
contract B is A { contract B is A {
function f() public view { function f() public view override {
assert(x == 0); assert(x == 0);
} }
} }
// ---- // ----
// Warning: (113-127): Assertion violation happens here // Warning: (113-127): Assertion violation happens here
// Warning: (162-176): Assertion violation happens here // Warning: (162-176): Assertion violation happens here
// Warning: (259-273): Assertion violation happens here // Warning: (268-282): Assertion violation happens here
// Warning: (162-176): Assertion violation happens here // Warning: (162-176): Assertion violation happens here

View File

@ -16,12 +16,12 @@ contract A {
contract B is A { contract B is A {
uint y; uint y;
function f() public view { function f() public view override {
assert(x == 0); assert(x == 0);
} }
} }
// ---- // ----
// Warning: (113-127): Assertion violation happens here // Warning: (113-127): Assertion violation happens here
// Warning: (162-176): Assertion violation happens here // Warning: (162-176): Assertion violation happens here
// Warning: (269-283): Assertion violation happens here // Warning: (278-292): Assertion violation happens here
// Warning: (162-176): Assertion violation happens here // Warning: (162-176): Assertion violation happens here

View File

@ -16,7 +16,7 @@ contract A {
contract B is A { contract B is A {
uint y; uint y;
function f() public view { function f() public view override {
assert(x == 0); assert(x == 0);
} }
function h() public view { function h() public view {
@ -28,7 +28,7 @@ contract B is A {
contract C is B { contract C is B {
uint z; uint z;
function f() public view { function f() public view override {
assert(x == 0); assert(x == 0);
} }
function i() public view { function i() public view {
@ -38,10 +38,10 @@ contract C is B {
// ---- // ----
// Warning: (113-127): Assertion violation happens here // Warning: (113-127): Assertion violation happens here
// Warning: (162-176): Assertion violation happens here // Warning: (162-176): Assertion violation happens here
// Warning: (271-285): Assertion violation happens here // Warning: (280-294): Assertion violation happens here
// Warning: (320-334): Assertion violation happens here // Warning: (329-343): Assertion violation happens here
// Warning: (162-176): Assertion violation happens here // Warning: (162-176): Assertion violation happens here
// Warning: (434-448): Assertion violation happens here // Warning: (452-466): Assertion violation happens here
// Warning: (483-497): Assertion violation happens here // Warning: (501-515): Assertion violation happens here
// Warning: (320-334): Assertion violation happens here // Warning: (329-343): Assertion violation happens here
// Warning: (162-176): Assertion violation happens here // Warning: (162-176): Assertion violation happens here

View File

@ -0,0 +1,27 @@
pragma experimental SMTChecker;
// 2 warnings, receive and A.g
contract A {
uint x;
receive () external payable {
assert(x == 1);
}
function g() public view {
assert(x == 1);
}
}
// 2 warnings, receive and A.g
contract B is A {
uint y;
receive () external payable override {
assert(x == 0);
}
}
// ----
// Warning: (120-134): Assertion violation happens here
// Warning: (169-183): Assertion violation happens here
// Warning: (292-306): Assertion violation happens here
// Warning: (169-183): Assertion violation happens here

View File

@ -0,0 +1,28 @@
pragma experimental SMTChecker;
// 2 warnings, receive and A.g
contract A {
uint x;
receive () external payable {
assert(x == 1);
}
function g() public view {
assert(x == 1);
}
}
// 3 warnings, fallback, A.receive and A.g
contract B is A {
uint y;
fallback () external {
assert(x == 0);
}
}
// ----
// Warning: (120-134): Assertion violation happens here
// Warning: (169-183): Assertion violation happens here
// Warning: (288-302): Assertion violation happens here
// Warning: (120-134): Assertion violation happens here
// Warning: (169-183): Assertion violation happens here