Adding more tests for function types

This commit is contained in:
chriseth
2020-07-23 14:55:32 +02:00
committed by Djordje Mijovic
parent e7d5a7da10
commit a1da90d14b
7 changed files with 74 additions and 0 deletions
@@ -0,0 +1,9 @@
contract C {
function f() pure public {
function(uint a) returns (uint) x;
x({a:2});
}
}
// ----
// Warning 6162: (61-67): Naming function type parameters is deprecated.
// TypeError 4974: (95-103): Named argument "a" does not match function declaration.
@@ -0,0 +1,13 @@
library L {
function f(uint a) internal pure {}
function g(uint a) internal pure {}
}
contract C {
using L for *;
function f() pure public {
uint t = 8;
[t.f, t.g][0]();
}
}
// ----
// TypeError 9563: (186-189): Invalid mobile type.
@@ -0,0 +1,13 @@
library L {
function f(uint a) internal pure {}
}
contract C {
using L for *;
function f() pure public {
uint t;
function() pure x;
[t.f, x][0]({a: 8});
}
}
// ----
// TypeError 9563: (169-172): Invalid mobile type.
@@ -0,0 +1,13 @@
contract D {
function f(uint a) external payable {}
function g(uint a) external {}
}
contract C {
function f() public {
D d;
[d.f{value: 1}, d.g][0](8);
}
}
// ----
// TypeError 9563: (155-168): Invalid mobile type.
@@ -0,0 +1,14 @@
library L {
function f(uint a) internal pure {}
function g(uint a) internal pure {}
}
contract C {
using L for *;
function f(bool x) pure public {
uint t = 8;
(x ? t.f : t.g)();
}
}
// ----
// TypeError 9717: (196-199): Invalid mobile type in true expression.
// TypeError 3703: (202-205): Invalid mobile type in false expression.