aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests/parsing
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-04-14 00:39:31 +0800
committerGitHub <noreply@github.com>2018-04-14 00:39:31 +0800
commit95c49b367eaaec313b335d0953b5871dd445052c (patch)
tree150f88f057eaafed3d9a26f94b039b1bf7a4054b /test/libsolidity/syntaxTests/parsing
parent2001cc6bdca87d715380b15f11c797666528e040 (diff)
parentbe37e3a912f6d5a2a57544f60362be65b7be8284 (diff)
downloaddexon-solidity-95c49b367eaaec313b335d0953b5871dd445052c.tar.gz
dexon-solidity-95c49b367eaaec313b335d0953b5871dd445052c.tar.zst
dexon-solidity-95c49b367eaaec313b335d0953b5871dd445052c.zip
Merge pull request #3875 from ethereum/constructorSelfRef
Stricter check for "this" in constructor.
Diffstat (limited to 'test/libsolidity/syntaxTests/parsing')
-rw-r--r--test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol28
-rw-r--r--test/libsolidity/syntaxTests/parsing/constructor_super.sol10
2 files changed, 38 insertions, 0 deletions
diff --git a/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol
new file mode 100644
index 00000000..9f714aea
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/constructor_allowed_this.sol
@@ -0,0 +1,28 @@
+contract A {
+ function a() public pure {
+ }
+}
+contract B {
+ constructor(address) public {
+ }
+ function b(address) public returns (A) {
+ return new A();
+ }
+}
+contract C {
+ B m_b;
+ C m_c;
+ constructor(C other_c) public {
+ m_c = other_c;
+ m_b = new B(this);
+ m_b.b(this).a();
+ g(this).f();
+ other_c.f();
+ m_c.f();
+ }
+ function f() public pure {
+ }
+ function g(C) public view returns (C) {
+ return m_c;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/constructor_super.sol b/test/libsolidity/syntaxTests/parsing/constructor_super.sol
new file mode 100644
index 00000000..fa1be187
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/constructor_super.sol
@@ -0,0 +1,10 @@
+contract A {
+ function x() pure internal {}
+}
+
+contract B is A {
+ constructor() public {
+ // used to trigger warning about using ``this`` in constructor
+ super.x();
+ }
+}