From 26cf6f189d5dbb993bc967e04f7a0e07da53cccc Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 3 Nov 2020 11:47:08 +0100 Subject: [PATCH] Test with storage struct containing external function. --- .../struct_with_external_function.sol | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/libsolidity/semanticTests/functionTypes/struct_with_external_function.sol diff --git a/test/libsolidity/semanticTests/functionTypes/struct_with_external_function.sol b/test/libsolidity/semanticTests/functionTypes/struct_with_external_function.sol new file mode 100644 index 000000000..19086df7a --- /dev/null +++ b/test/libsolidity/semanticTests/functionTypes/struct_with_external_function.sol @@ -0,0 +1,34 @@ +struct S { + uint16 a; + function() external returns (uint) x; + uint16 b; +} +contract Flow { + S[2] t; + + function X() public pure returns (uint) { + return 1; + } + + function Y() public pure returns (uint) { + return 2; + } + + constructor() { + t[0].a = 0xff07; + t[0].b = 0xff07; + t[1].x = this.Y; + t[1].a = 0xff07; + t[1].b = 0xff07; + t[0].x = this.X; + } + + function f() public returns (uint, uint) { + return (t[0].x(), t[1].x()); + } +} + +// ==== +// compileViaYul: also +// ---- +// f() -> 1, 2