-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stricter check for member access to "this" in constructor.
- Loading branch information
Showing
5 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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: (172-176): "this" used in constructor. | ||
// Warning: (191-195): "this" used in constructor. |
8 changes: 8 additions & 0 deletions
8
test/libsolidity/syntaxTests/parsing/constructor_self_ref.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
contract Foo { | ||
bool public bar; | ||
|
||
constructor(Foo other) public { | ||
require(other.bar()); | ||
} | ||
} | ||
// ---- |
19 changes: 19 additions & 0 deletions
19
test/libsolidity/syntaxTests/parsing/constructor_super.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
contract A { | ||
function x() pure internal {} | ||
} | ||
|
||
contract B is A { | ||
constructor() public { | ||
super.x(); | ||
} | ||
|
||
function x() pure internal { | ||
require(false); | ||
} | ||
} | ||
|
||
contract C is A { | ||
constructor() public { | ||
x(); | ||
} | ||
} |