From e24a23edcd0676436780c5be29431e89f212955a Mon Sep 17 00:00:00 2001 From: hrkrshnn Date: Fri, 12 Feb 2021 20:01:01 +0100 Subject: [PATCH] Semantic test where constructor has a function as parameter --- .../constructor_function_argument.sol | 9 ++++++++ .../constructor_function_complex.sol | 21 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 test/libsolidity/semanticTests/constructor/constructor_function_argument.sol create mode 100644 test/libsolidity/semanticTests/constructor/constructor_function_complex.sol diff --git a/test/libsolidity/semanticTests/constructor/constructor_function_argument.sol b/test/libsolidity/semanticTests/constructor/constructor_function_argument.sol new file mode 100644 index 000000000..b52f10de0 --- /dev/null +++ b/test/libsolidity/semanticTests/constructor/constructor_function_argument.sol @@ -0,0 +1,9 @@ +// The IR of this test used to throw +contract D { + constructor(function() external returns (uint)) { + } +} +// ==== +// compileViaYul: also +// ---- +// constructor(): 0xfdd67305928fcac8d213d1e47bfa6165cd0b87b946644cd0000000000000000 -> diff --git a/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol b/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol new file mode 100644 index 000000000..1fbb16c2a --- /dev/null +++ b/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol @@ -0,0 +1,21 @@ +contract D { + uint public x; + constructor(function() external pure returns (uint) g) { + x = g(); + } +} + +contract C { + function f() public returns (uint r) { + D d = new D(this.sixteen); + r = d.x(); + } + + function sixteen() public pure returns (uint) { + return 16; + } +} +// ==== +// compileViaYul: also +// ---- +// f() -> 16