mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[SMTChecker] Fix constructors with local vars
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
pragma experimental SMTChecker;
|
||||
contract F {
|
||||
uint a;
|
||||
constructor() public {
|
||||
uint f = 2;
|
||||
a = f;
|
||||
}
|
||||
}
|
||||
|
||||
contract E is F {}
|
||||
contract D is E {
|
||||
constructor() public {
|
||||
uint d = 3;
|
||||
a = d;
|
||||
}
|
||||
}
|
||||
contract C is D {}
|
||||
contract B is C {
|
||||
constructor() public {
|
||||
uint b = 4;
|
||||
a = b;
|
||||
}
|
||||
}
|
||||
|
||||
contract A is B {
|
||||
constructor(uint x) public {
|
||||
uint a1 = 4;
|
||||
uint a2 = 5;
|
||||
assert(a == a1);
|
||||
assert(a == a2);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (317-323): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
||||
// Warning: (385-400): Assertion violation happens here
|
||||
@@ -0,0 +1,13 @@
|
||||
pragma experimental SMTChecker;
|
||||
contract C {
|
||||
function f() public pure {}
|
||||
constructor() public {
|
||||
C c = this;
|
||||
c.f(); // this does not warn now, but should warn in the future
|
||||
this.f();
|
||||
(this).f();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (204-208): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed.
|
||||
// Warning: (223-227): "this" used in constructor. Note that external functions of a contract cannot be called while it is being constructed.
|
||||
Reference in New Issue
Block a user