mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Split out SolidityNameAndTypeResolution tests into SyntaxTests
This commit is contained in:
parent
deeca7bc5d
commit
6e23006937
@ -0,0 +1,4 @@
|
||||
contract test {
|
||||
uint256 variable;
|
||||
function f(uint256) public returns (uint out) { f(variable); test; out; }
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
contract test {
|
||||
uint256 variable;
|
||||
function f(uint256 arg) public {
|
||||
f(notfound);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (85-93): Undeclared identifier.
|
@ -0,0 +1,10 @@
|
||||
contract test {
|
||||
uint256 variable;
|
||||
function f(uint256 arg) public {
|
||||
f(notfound);
|
||||
f(notfound);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (85-93): Undeclared identifier.
|
||||
// DeclarationError: (106-114): Undeclared identifier.
|
@ -0,0 +1,6 @@
|
||||
contract test {
|
||||
function g() public { f(); }
|
||||
function f() public {}
|
||||
}
|
||||
// ----
|
||||
// Warning: (53-75): Function state mutability can be restricted to pure
|
@ -0,0 +1,8 @@
|
||||
contract test {
|
||||
function f(uint256 arg1, uint32 arg2) public returns (bool ret) {
|
||||
var x = arg1 + arg2 == 8; ret = x;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (94-99): Use of the "var" keyword is deprecated.
|
||||
// Warning: (20-134): Function state mutability can be restricted to pure
|
@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
function f() public returns (bool r) { return 1 >= 2; }
|
||||
}
|
||||
// ----
|
||||
// Warning: (20-75): Function state mutability can be restricted to pure
|
@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
function f() public returns (bool r1, bool r2) { return 1 >= 2; }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (69-82): Different number of arguments in return statement than in returns declaration.
|
@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
function f() public returns (uint256 r) { return 1 >= 2; }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (69-75): Return argument type bool is not implicitly convertible to expected type (type of first return variable) uint256.
|
@ -0,0 +1,6 @@
|
||||
contract test {
|
||||
function f() public returns (bool) { return g(12, true) == 3; }
|
||||
function g(uint256, bool) public returns (uint256) { }
|
||||
}
|
||||
// ----
|
||||
// Warning: (88-142): Function state mutability can be restricted to pure
|
@ -0,0 +1,6 @@
|
||||
contract test {
|
||||
function f() public { uint32(2) == int64(2); }
|
||||
}
|
||||
// ----
|
||||
// Warning: (42-63): Statement has no effect.
|
||||
// Warning: (20-66): Function state mutability can be restricted to pure
|
@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
function f() public { int32(2) == uint64(2); }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (42-63): Operator == not compatible with types int32 and uint64
|
@ -0,0 +1,6 @@
|
||||
contract test {
|
||||
function f() public returns (int256 r) { var x = int256(uint32(2)); return x; }
|
||||
}
|
||||
// ----
|
||||
// Warning: (61-66): Use of the "var" keyword is deprecated.
|
||||
// Warning: (20-99): Function state mutability can be restricted to pure
|
@ -0,0 +1,7 @@
|
||||
contract test {
|
||||
function f() public { var x = "123456789012345678901234567890123"; }
|
||||
}
|
||||
// ----
|
||||
// Warning: (42-47): Use of the "var" keyword is deprecated.
|
||||
// Warning: (42-47): Unused local variable.
|
||||
// Warning: (20-88): Function state mutability can be restricted to pure
|
@ -0,0 +1,8 @@
|
||||
contract test {
|
||||
function fun() public {
|
||||
uint256 x = address(0).balance;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (52-61): Unused local variable.
|
||||
// Warning: (20-89): Function state mutability can be restricted to view
|
@ -0,0 +1,7 @@
|
||||
contract test {
|
||||
function fun() public {
|
||||
address(0).balance = 7;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (52-70): Expression has to be an lvalue.
|
@ -0,0 +1,13 @@
|
||||
contract test {
|
||||
struct str {
|
||||
mapping(uint=>uint) map;
|
||||
}
|
||||
str data;
|
||||
function fun() public {
|
||||
var a = data.map;
|
||||
data.map = a;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (122-127): Use of the "var" keyword is deprecated.
|
||||
// TypeError: (148-160): Mappings cannot be assigned to.
|
@ -0,0 +1,12 @@
|
||||
contract test {
|
||||
struct str {
|
||||
mapping(uint=>uint) map;
|
||||
}
|
||||
str data;
|
||||
function fun() public {
|
||||
var a = data;
|
||||
data = a;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (122-127): Use of the "var" keyword is deprecated.
|
@ -0,0 +1,10 @@
|
||||
contract First {
|
||||
function fun() public returns (bool) {
|
||||
return Second(1).fun(1, true, 3) > 0;
|
||||
}
|
||||
}
|
||||
contract Second {
|
||||
function fun(uint, bool, uint) public returns (uint) {
|
||||
if (First(2).fun() == true) return 1;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
contract First {
|
||||
function fun() public returns (bool ret) {
|
||||
return 1 & 2 == 8 & 9 && 1 ^ 2 < 4 | 6;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (21-117): Function state mutability can be restricted to pure
|
@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
function f() public returns (bool ret) {
|
||||
return this.f < this.f;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (73-88): Operator < not compatible with types function () external returns (bool) and function () external returns (bool)
|
@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
function f() public returns (bool ret) {
|
||||
return f < f;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (73-78): Operator < not compatible with types function () returns (bool) and function () returns (bool)
|
@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
function f() public returns (bool ret) {
|
||||
return this.f > this.f;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (73-88): Operator > not compatible with types function () external returns (bool) and function () external returns (bool)
|
@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
function f() public returns (bool ret) {
|
||||
return f > f;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (73-78): Operator > not compatible with types function () returns (bool) and function () returns (bool)
|
@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
function f() public returns (bool ret) {
|
||||
return f == f;
|
||||
}
|
||||
function g() public returns (bool ret) {
|
||||
return f != f;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (17-86): Function state mutability can be restricted to pure
|
||||
// Warning: (91-160): Function state mutability can be restricted to pure
|
@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
mapping(uint => uint) x;
|
||||
function f() public returns (bool ret) {
|
||||
var y = x;
|
||||
return x == y;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (95-100): Use of the "var" keyword is deprecated.
|
||||
// TypeError: (121-127): Operator == not compatible with types mapping(uint256 => uint256) and mapping(uint256 => uint256)
|
@ -0,0 +1,7 @@
|
||||
contract base { function foo(); }
|
||||
contract derived {
|
||||
base b;
|
||||
function foo() public { b = new base(); }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (97-105): Trying to create an instance of an abstract contract.
|
@ -0,0 +1,5 @@
|
||||
contract base { function foo(); }
|
||||
contract derived is base { function foo() public {} }
|
||||
contract wrong is derived { function foo(); }
|
||||
// ----
|
||||
// TypeError: (116-131): Redeclaring an already implemented function as abstract
|
@ -0,0 +1,13 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S1 { }
|
||||
struct S2 { }
|
||||
function f(S1) pure {}
|
||||
function f(S2) pure {}
|
||||
}
|
||||
// ----
|
||||
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
|
||||
// Warning: (52-65): Defining empty structs is deprecated.
|
||||
// Warning: (70-83): Defining empty structs is deprecated.
|
||||
// TypeError: (115-137): Function overload clash during conversion to external types for arguments.
|
@ -0,0 +1,12 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S1 { function() external a; }
|
||||
struct S2 { bytes24 a; }
|
||||
function f(S1) pure {}
|
||||
function f(S2) pure {}
|
||||
}
|
||||
// ----
|
||||
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
|
||||
// Warning: (122-144): No visibility specified. Defaulting to "public".
|
||||
// Warning: (149-171): No visibility specified. Defaulting to "public".
|
@ -0,0 +1,9 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S { function() internal a; }
|
||||
function f(S) {}
|
||||
}
|
||||
// ----
|
||||
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
|
||||
// TypeError: (103-104): Internal or recursive type is not allowed for public or external functions.
|
@ -0,0 +1,9 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S { mapping(uint => uint) a; }
|
||||
function f(S) {}
|
||||
}
|
||||
// ----
|
||||
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
|
||||
// TypeError: (105-106): Internal or recursive type is not allowed for public or external functions.
|
@ -0,0 +1,10 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct T { mapping(uint => uint) a; }
|
||||
struct S { T[][2] b; }
|
||||
function f(S) {}
|
||||
}
|
||||
// ----
|
||||
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
|
||||
// TypeError: (132-133): Internal or recursive type is not allowed for public or external functions.
|
@ -0,0 +1,7 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
function f() public pure returns (string[][]) {}
|
||||
}
|
||||
// ----
|
||||
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
|
@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
function f() public pure returns (string[][]) {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (51-61): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
|
@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
function f() public pure returns (uint[][2]) {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (51-60): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
|
@ -0,0 +1,8 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract C {
|
||||
struct S { string[] s; }
|
||||
function f() public pure returns (S) {}
|
||||
}
|
||||
// ----
|
||||
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
|
@ -0,0 +1,6 @@
|
||||
contract C {
|
||||
struct S { string[] s; }
|
||||
function f() public pure returns (S x) {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (80-83): This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
|
@ -0,0 +1,11 @@
|
||||
contract C {}
|
||||
contract Test {
|
||||
function externalCall() public {
|
||||
C arg;
|
||||
this.g(arg);
|
||||
}
|
||||
function g (C c) external {}
|
||||
}
|
||||
// ----
|
||||
// Warning: (125-128): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
||||
// Warning: (113-141): Function state mutability can be restricted to pure
|
@ -0,0 +1,10 @@
|
||||
contract C {}
|
||||
contract Test {
|
||||
function externalCall() public {
|
||||
address arg;
|
||||
this.g(arg);
|
||||
}
|
||||
function g (C c) external {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (103-106): Invalid type for argument in function call. Invalid implicit conversion from address to contract C requested.
|
@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
uint a;
|
||||
}
|
||||
contract Test {
|
||||
C a;
|
||||
function g (C c) public {}
|
||||
function internalCall() public {
|
||||
g(a);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (68-71): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
||||
// Warning: (56-82): Function state mutability can be restricted to pure
|
@ -0,0 +1,12 @@
|
||||
contract C {
|
||||
uint a;
|
||||
}
|
||||
contract Test {
|
||||
address a;
|
||||
function g (C c) public {}
|
||||
function internalCall() public {
|
||||
g(a);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (136-137): Invalid type for argument in function call. Invalid implicit conversion from address to contract C requested.
|
@ -0,0 +1,6 @@
|
||||
contract test {
|
||||
function gsf() public { }
|
||||
function tgeo() public { }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (0-78): Function signature hash collision for tgeo()
|
@ -0,0 +1,5 @@
|
||||
contract base { uint baseMember; struct BaseType { uint element; } }
|
||||
contract derived is base {
|
||||
BaseType data;
|
||||
function f() public { baseMember = 7; }
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
contract root { function rootFunction() public {} }
|
||||
contract inter1 is root { function f() public {} }
|
||||
contract inter2 is root { function f() public {} }
|
||||
contract derived is root, inter2, inter1 {
|
||||
function g() public { f(); rootFunction(); }
|
||||
}
|
||||
// ----
|
||||
// Warning: (16-49): Function state mutability can be restricted to pure
|
||||
// Warning: (129-151): Function state mutability can be restricted to pure
|
@ -0,0 +1,4 @@
|
||||
contract A is B { }
|
||||
contract B is A { }
|
||||
// ----
|
||||
// TypeError: (14-15): Definition of base has to precede definition of derived contract
|
@ -0,0 +1,6 @@
|
||||
contract B { function f() public {} }
|
||||
contract C is B { function f(uint i) public {} }
|
||||
// ----
|
||||
// Warning: (67-73): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
||||
// Warning: (13-35): Function state mutability can be restricted to pure
|
||||
// Warning: (56-84): Function state mutability can be restricted to pure
|
@ -0,0 +1,7 @@
|
||||
contract A { function f(uint a) public {} }
|
||||
contract B { function f() public {} }
|
||||
contract C is A, B { }
|
||||
// ----
|
||||
// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
||||
// Warning: (13-41): Function state mutability can be restricted to pure
|
||||
// Warning: (57-79): Function state mutability can be restricted to pure
|
@ -0,0 +1,4 @@
|
||||
contract B { function f() internal {} }
|
||||
contract C is B { function f() public {} }
|
||||
// ----
|
||||
// TypeError: (58-80): Overriding function visibility differs.
|
@ -0,0 +1,6 @@
|
||||
contract A { function f() public { uint8 x = C(0).g(); } }
|
||||
contract B { function f() public {} function g() public returns (uint8) {} }
|
||||
contract C is A, B { }
|
||||
// ----
|
||||
// Warning: (35-42): Unused local variable.
|
||||
// Warning: (95-133): Function state mutability can be restricted to pure
|
@ -0,0 +1,5 @@
|
||||
contract A { function A(uint a) public { } }
|
||||
contract B is A { }
|
||||
// ----
|
||||
// Warning: (13-42): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
|
||||
// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
@ -0,0 +1,5 @@
|
||||
contract A { function A(uint a) public { } }
|
||||
contract B is A { }
|
||||
// ----
|
||||
// Warning: (13-42): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
|
||||
// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
@ -0,0 +1,7 @@
|
||||
contract A { }
|
||||
contract B is A {
|
||||
function f() public { A a = B(1); }
|
||||
}
|
||||
// ----
|
||||
// Warning: (59-62): Unused local variable.
|
||||
// Warning: (37-72): Function state mutability can be restricted to pure
|
@ -0,0 +1,6 @@
|
||||
contract A { }
|
||||
contract B is A {
|
||||
function f() public { B b = A(1); }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (59-69): Type contract A is not implicitly convertible to expected type contract B.
|
@ -0,0 +1,11 @@
|
||||
contract A {
|
||||
function b() public {}
|
||||
}
|
||||
|
||||
contract B is A {
|
||||
function f() public {
|
||||
super.f();
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (95-102): Member "f" not found or not visible after argument-dependent lookup in contract super B
|
@ -0,0 +1,9 @@
|
||||
contract test {
|
||||
function fun() public {
|
||||
uint64(2);
|
||||
}
|
||||
uint256 foo;
|
||||
function foo() public {}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (90-114): Identifier already declared.
|
@ -0,0 +1,9 @@
|
||||
// test for issue #1126 https://github.com/ethereum/cpp-ethereum/issues/1126
|
||||
contract Parent {
|
||||
uint256 public m_aMember;
|
||||
}
|
||||
contract Child is Parent {
|
||||
function foo() public returns (uint256) { return Parent.m_aMember; }
|
||||
}
|
||||
// ----
|
||||
// Warning: (158-226): Function state mutability can be restricted to pure
|
@ -0,0 +1,6 @@
|
||||
contract test {
|
||||
struct Data { uint[15] m_array; }
|
||||
Data public data;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (58-74): Internal or recursive type is not allowed for public state variables.
|
@ -0,0 +1,8 @@
|
||||
contract Parent {
|
||||
uint256 internal m_aMember;
|
||||
}
|
||||
contract Child is Parent {
|
||||
function foo() public returns (uint256) { return Parent.m_aMember; }
|
||||
}
|
||||
// ----
|
||||
// Warning: (83-151): Function state mutability can be restricted to pure
|
@ -0,0 +1,11 @@
|
||||
contract Parent1 {
|
||||
uint256 internal m_aMember1;
|
||||
}
|
||||
contract Parent2 is Parent1 {
|
||||
uint256 internal m_aMember2;
|
||||
}
|
||||
contract Child is Parent2 {
|
||||
function foo() public returns (uint256) { return Parent2.m_aMember1; }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (200-218): Member "m_aMember1" not found or not visible after argument-dependent lookup in type(contract Parent2)
|
@ -0,0 +1,12 @@
|
||||
contract Parent1 {
|
||||
uint256 internal m_aMember1;
|
||||
}
|
||||
contract Parent2 is Parent1 {
|
||||
uint256 internal m_aMember2;
|
||||
}
|
||||
contract Child is Parent2 {
|
||||
function foo() public returns (uint256) { return Child.m_aMember2; }
|
||||
uint256 public m_aMember3;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (200-216): Member "m_aMember2" not found or not visible after argument-dependent lookup in type(contract Child)
|
@ -0,0 +1,4 @@
|
||||
contract C {
|
||||
uint x;
|
||||
function() public { x = 2; }
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
contract C {
|
||||
uint x;
|
||||
function(uint a) public { x = 2; }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (37-45): Fallback function cannot take parameters.
|
@ -0,0 +1,5 @@
|
||||
library C {
|
||||
function() public {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (16-36): Libraries cannot have fallback functions.
|
@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
function() public returns (uint) { }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (43-49): Fallback function cannot return values.
|
@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
uint x;
|
||||
function() public { x = 2; }
|
||||
function() public { x = 3; }
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (62-90): Only one fallback function is allowed.
|
@ -0,0 +1,7 @@
|
||||
contract A {
|
||||
uint x;
|
||||
function() public { x = 1; }
|
||||
}
|
||||
contract C is A {
|
||||
function() public { x = 2; }
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
contract c {
|
||||
event e(uint indexed a, bytes3 indexed s, bool indexed b);
|
||||
function f() public { e(2, "abc", true); }
|
||||
}
|
||||
// ----
|
||||
// Warning: (102-119): Invoking events without "emit" prefix is deprecated.
|
@ -0,0 +1,5 @@
|
||||
contract c {
|
||||
event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d);
|
||||
}
|
||||
// ----
|
||||
// TypeError: (17-91): More than 3 indexed arguments for event.
|
@ -0,0 +1,3 @@
|
||||
contract c {
|
||||
event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d) anonymous;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
contract c {
|
||||
event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d, uint indexed e) anonymous;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (17-117): More than 4 indexed arguments for anonymous event.
|
@ -0,0 +1,4 @@
|
||||
contract TestIt {
|
||||
event A();
|
||||
event A(uint i);
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
contract test {
|
||||
event A(uint);
|
||||
event A(uint, uint);
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
contract test {
|
||||
event A(uint);
|
||||
event A(bytes);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
contract test {
|
||||
event A(uint i);
|
||||
event A(uint i);
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (20-36): Event with same name and arguments defined twice.
|
@ -0,0 +1,6 @@
|
||||
contract test {
|
||||
event A(uint i);
|
||||
event A(uint i) anonymous;
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (20-36): Event with same name and arguments defined twice.
|
@ -0,0 +1,6 @@
|
||||
contract test {
|
||||
event A(uint i);
|
||||
event A(uint indexed i);
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (20-36): Event with same name and arguments defined twice.
|
@ -0,0 +1,6 @@
|
||||
contract c {
|
||||
event e(uint a, bytes3 indexed s, bool indexed b);
|
||||
function f() public { e(2, "abc", true); }
|
||||
}
|
||||
// ----
|
||||
// Warning: (94-111): Invoking events without "emit" prefix is deprecated.
|
@ -0,0 +1,12 @@
|
||||
contract A {
|
||||
function dup() public returns (uint) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
contract B {
|
||||
event dup();
|
||||
}
|
||||
contract C is A, B {
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (99-111): Identifier already declared.
|
@ -0,0 +1,12 @@
|
||||
contract B {
|
||||
event dup();
|
||||
}
|
||||
contract A {
|
||||
function dup() public returns (uint) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
contract C is B, A {
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (49-111): Identifier already declared.
|
@ -0,0 +1,8 @@
|
||||
contract A {
|
||||
event dup();
|
||||
function dup() public returns (uint) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError: (34-96): Identifier already declared.
|
@ -0,0 +1,8 @@
|
||||
contract base {
|
||||
event e(uint a, bytes3 indexed s, bool indexed b);
|
||||
}
|
||||
contract c is base {
|
||||
function f() public { e(2, "abc", true); }
|
||||
}
|
||||
// ----
|
||||
// Warning: (120-137): Invoking events without "emit" prefix is deprecated.
|
@ -0,0 +1,4 @@
|
||||
contract c {
|
||||
event e1(uint a, uint e1, uint e2);
|
||||
event e2(uint a, uint e1, uint e2);
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
contract c {
|
||||
function f() public {}
|
||||
}
|
||||
contract d {
|
||||
function g() public { c(0).f(); }
|
||||
}
|
||||
// ----
|
||||
// Warning: (17-39): Function state mutability can be restricted to pure
|
@ -0,0 +1,8 @@
|
||||
contract c {
|
||||
function f() internal {}
|
||||
}
|
||||
contract d {
|
||||
function g() public { c(0).f(); }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (83-89): Member "f" not found or not visible after argument-dependent lookup in contract c
|
@ -0,0 +1,8 @@
|
||||
contract c {
|
||||
uint a;
|
||||
}
|
||||
contract d {
|
||||
function g() public { c(0).a(); }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (66-72): Member "a" not found or not visible after argument-dependent lookup in contract c
|
@ -0,0 +1,8 @@
|
||||
contract c {
|
||||
uint public a;
|
||||
}
|
||||
contract d {
|
||||
function g() public { c(0).a(); }
|
||||
}
|
||||
// ----
|
||||
// Warning: (51-84): Function state mutability can be restricted to view
|
@ -0,0 +1,11 @@
|
||||
contract test {
|
||||
function a(uint a, uint b) public returns (uint r) {
|
||||
r = a + b;
|
||||
}
|
||||
function b() public returns (uint r) {
|
||||
r = a({a: 1});
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (31-37): This declaration shadows an existing declaration.
|
||||
// TypeError: (153-162): Wrong argument count for function call: 1 arguments given but expected 2.
|
@ -0,0 +1,11 @@
|
||||
contract test {
|
||||
function a(uint a, uint b) public returns (uint r) {
|
||||
r = a + b;
|
||||
}
|
||||
function b() public returns (uint r) {
|
||||
r = a({});
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (31-37): This declaration shadows an existing declaration.
|
||||
// TypeError: (153-158): Wrong argument count for function call: 0 arguments given but expected 2.
|
@ -0,0 +1,11 @@
|
||||
contract test {
|
||||
function a(uint a, uint b) public returns (uint r) {
|
||||
r = a + b;
|
||||
}
|
||||
function b() public returns (uint r) {
|
||||
r = a({a: 1, a: 2});
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (31-37): This declaration shadows an existing declaration.
|
||||
// TypeError: (159-160): Duplicate named argument.
|
@ -0,0 +1,11 @@
|
||||
contract test {
|
||||
function a(uint a, uint b) public returns (uint r) {
|
||||
r = a + b;
|
||||
}
|
||||
function b() public returns (uint r) {
|
||||
r = a({a: 1, c: 2});
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (31-37): This declaration shadows an existing declaration.
|
||||
// TypeError: (153-168): Named argument does not match function declaration.
|
@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
function f(uint) public { }
|
||||
}
|
||||
// ----
|
||||
// Warning: (20-47): Function state mutability can be restricted to pure
|
@ -0,0 +1,7 @@
|
||||
contract test {
|
||||
function f(uint[] constant a) public { }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (31-48): Illegal use of "constant" specifier.
|
||||
// TypeError: (31-48): Constants of non-value type not yet implemented.
|
||||
// TypeError: (31-48): Uninitialized "constant" variable.
|
@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
function f() public returns (bool) { }
|
||||
}
|
||||
// ----
|
||||
// Warning: (20-58): Function state mutability can be restricted to pure
|
@ -0,0 +1,7 @@
|
||||
contract test {
|
||||
function f(uint, uint k) public returns (uint ret_k) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (20-98): Function state mutability can be restricted to pure
|
@ -0,0 +1,7 @@
|
||||
contract test {
|
||||
function f() public returns (uint ret_k, uint) {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (77-85): Different number of arguments in return statement than in returns declaration.
|
@ -0,0 +1,7 @@
|
||||
contract c {
|
||||
function f() public { var (x) = f(); }
|
||||
}
|
||||
// ----
|
||||
// Warning: (44-45): Use of the "var" keyword is deprecated.
|
||||
// Warning: (39-52): Different number of components on the left hand side (1) than on the right hand side (0).
|
||||
// TypeError: (39-52): Not enough components (0) in value to assign all variables (1).
|
@ -0,0 +1,8 @@
|
||||
contract c {
|
||||
function c () public {
|
||||
a = 115792089237316195423570985008687907853269984665640564039458;
|
||||
}
|
||||
uint256 a;
|
||||
}
|
||||
// ----
|
||||
// Warning: (17-119): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
|
@ -0,0 +1,9 @@
|
||||
contract c {
|
||||
function c () public {
|
||||
a = 115792089237316195423570985008687907853269984665640564039458 ether;
|
||||
}
|
||||
uint256 a;
|
||||
}
|
||||
// ----
|
||||
// Warning: (17-125): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
|
||||
// TypeError: (52-118): Type int_const 1157...(70 digits omitted)...0000 is not implicitly convertible to expected type uint256.
|
@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
function f() public returns (uint d) { return 2 ** 10000000000; }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (66-82): Operator ** not compatible with types int_const 2 and int_const 10000000000
|
@ -0,0 +1,8 @@
|
||||
contract test {
|
||||
function f() pure public returns(uint) {
|
||||
uint8 x = 100;
|
||||
return 10**x;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (99-104): Result of exponentiation has type uint8 and thus might overflow. Silence this warning by converting the literal to the expected type.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user