Remove special treatment of `var`.

This commit is contained in:
chriseth
2020-07-20 17:22:04 +02:00
parent f945163909
commit 93c792c696
39 changed files with 272 additions and 535 deletions
@@ -1,8 +1,8 @@
contract C
{
function f ( ) public {
var i = ( ( 1 ( 3 ) ) , 2 );
( ( 1 ( 3 ) ) , 2 );
}
}
// ----
// TypeError 5704: (61-68): Type is not callable
// TypeError 5704: (53-60): Type is not callable
@@ -4,4 +4,4 @@
}
}
// ----
// TypeError 6651: (91-136): Data location must be "storage" for variable, but "memory" was given.
// TypeError 4061: (91-136): Type mapping(string => uint24)[1] is only valid in storage because it contains a (nested) mapping.
@@ -4,12 +4,11 @@ contract b {
}
c d;
function e() public {
var d = d;
function e() public view {
c storage x = d;
x.a[0];
}
}
// ----
// Warning 2519: (105-110): This declaration shadows an existing declaration.
// Warning 3408: (66-69): Variable "d" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.
// Warning 2332: (105-110): Type "b.c" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.
// SyntaxError 1719: (105-114): Use of the "var" keyword is disallowed. Use explicit declaration `struct b.c storage pointer d = ...´ instead.
// Warning 2332: (110-111): Type "b.c" covers a large part of storage and thus makes collisions likely. Either use mappings or dynamic arrays and allow their size to be increased only in small quantities per transaction.
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
// TypeError 6651: (47-77): Data location must be "storage" for variable, but "memory" was given.
// TypeError 4061: (47-77): Type mapping(uint256 => uint256)[] is only valid in storage because it contains a (nested) mapping.
@@ -2,8 +2,8 @@ contract C {
struct S { uint a; uint b; mapping(uint=>uint) c; }
function f() public {
S memory s = S({a: 1});
S({a: 1});
}
}
// ----
// TypeError 9515: (117-126): Struct containing a (nested) mapping cannot be constructed.
// TypeError 9515: (104-113): Struct containing a (nested) mapping cannot be constructed.
@@ -2,4 +2,4 @@ contract Foo {
function f() { var memory x; }
}
// ----
// ParserError 7439: (35-41): Location specifier needs explicit type name.
// ParserError 6933: (31-34): Expected primary expression.
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
// ParserError 7059: (35-38): Expected explicit type name.
// ParserError 3546: (35-38): Expected type name
@@ -1,25 +0,0 @@
contract C {
function f() returns(var) {}
function f() returns(var x) {}
function f() returns(var x, uint y) {}
function f() returns(uint x, var y) {}
function f() returns(var x, var y) {}
function f() public pure returns (var storage) {}
function f() public pure returns (var storage x) {}
function f() public pure returns (var storage x, var storage y) {}
}
// ----
// ParserError 7059: (38-41): Expected explicit type name.
// ParserError 7059: (71-74): Expected explicit type name.
// ParserError 7059: (106-109): Expected explicit type name.
// ParserError 7059: (157-160): Expected explicit type name.
// ParserError 7059: (192-195): Expected explicit type name.
// ParserError 7059: (199-202): Expected explicit type name.
// ParserError 7059: (247-250): Expected explicit type name.
// ParserError 7439: (251-258): Location specifier needs explicit type name.
// ParserError 7059: (301-304): Expected explicit type name.
// ParserError 7439: (305-312): Location specifier needs explicit type name.
// ParserError 7059: (357-360): Expected explicit type name.
// ParserError 7439: (361-368): Location specifier needs explicit type name.
// ParserError 7059: (372-375): Expected explicit type name.
// ParserError 7439: (376-383): Location specifier needs explicit type name.
@@ -1,7 +1,7 @@
contract C {
function f() {
var a = (2 2);
uint a = (2 2);
}
}
// ----
// ParserError 2314: (42-43): Expected ',' but got 'Number'
// ParserError 2314: (43-44): Expected ',' but got 'Number'
@@ -2,4 +2,4 @@ contract Foo {
function f() { var[] a; }
}
// ----
// ParserError 2314: (34-35): Expected identifier but got '['
// ParserError 6933: (31-34): Expected primary expression.
@@ -1,25 +0,0 @@
contract C {
function f(var) public pure {}
function f(var x) public pure {}
function f(var x, var y) public pure {}
function f(uint x, var y) public pure {}
function f(var x, uint y) public pure {}
function f(var storage) public pure {}
function f(var storage x) public pure {}
function f(var storage x, var storage y) public pure {}
}
// ----
// ParserError 7059: (28-31): Expected explicit type name.
// ParserError 7059: (63-66): Expected explicit type name.
// ParserError 7059: (100-103): Expected explicit type name.
// ParserError 7059: (107-110): Expected explicit type name.
// ParserError 7059: (152-155): Expected explicit type name.
// ParserError 7059: (189-192): Expected explicit type name.
// ParserError 7059: (234-237): Expected explicit type name.
// ParserError 7439: (238-245): Location specifier needs explicit type name.
// ParserError 7059: (277-280): Expected explicit type name.
// ParserError 7439: (281-288): Location specifier needs explicit type name.
// ParserError 7059: (322-325): Expected explicit type name.
// ParserError 7439: (326-333): Location specifier needs explicit type name.
// ParserError 7059: (337-340): Expected explicit type name.
// ParserError 7439: (341-348): Location specifier needs explicit type name.
@@ -1,7 +0,0 @@
contract C {
struct S {
var x;
}
}
// ----
// ParserError 7059: (27-30): Expected explicit type name.
@@ -6,4 +6,4 @@ contract c {
}
}
// ----
// TypeError 6651: (81-113): Data location must be "storage" for variable, but "calldata" was given.
// TypeError 4061: (81-113): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping.
@@ -6,4 +6,4 @@ contract c {
}
}
// ----
// TypeError 6651: (81-104): Data location must be "storage" for variable, but none was given.
// TypeError 6651: (81-104): Data location must be "storage", "memory" or "calldata" for variable, but none was given.
@@ -6,4 +6,4 @@ contract c {
}
}
// ----
// TypeError 6651: (81-111): Data location must be "storage" for variable, but "memory" was given.
// TypeError 4061: (81-111): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping.
@@ -4,13 +4,11 @@ contract C {
function h() internal pure returns (uint, uint) { return (1, 2); }
function test() internal pure {
var () = f();
var () = g();
var (,) = h();
() = f();
() = g();
(,) = h();
}
}
// ----
// SyntaxError 3299: (223-235): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty.
// SyntaxError 3299: (245-257): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty.
// SyntaxError 3299: (267-280): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty.
// ParserError 6933: (224-225): Expected primary expression.
@@ -3,13 +3,14 @@ contract n
fallback() external
{
// Used to cause a segfault
var (x,y) = (1);
var (z) = ();
(uint x, ) = (1);
(uint z) = ();
assembly {
mstore(y, z)
mstore(x, z)
}
}
}
// ----
// TypeError 7364: (69-84): Different number of components on the left hand side (2) than on the right hand side (1).
// TypeError 7364: (69-85): Different number of components on the left hand side (2) than on the right hand side (1).
// TypeError 7364: (89-102): Different number of components on the left hand side (1) than on the right hand side (0).
@@ -1,9 +0,0 @@
contract C {
function f() public pure {
var ();
var (,);
}
}
// ----
// SyntaxError 3299: (52-58): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty.
// SyntaxError 3299: (68-75): The use of the "var" keyword is disallowed. The declaration part of the statement can be removed, since it is empty.
@@ -5,4 +5,4 @@ contract C {
}
}
// ----
// TypeError 6983: (52-57): Use of the "var" keyword is disallowed.
// ParserError 6933: (52-55): Expected primary expression.
@@ -6,4 +6,4 @@ contract C {
}
}
// ----
// TypeError 4626: (52-62): Use of the "var" keyword is disallowed.
// ParserError 6933: (52-55): Expected primary expression.
@@ -4,4 +4,4 @@ contract C {
}
}
// ----
// TypeError 4626: (52-63): Use of the "var" keyword is disallowed.
// ParserError 6933: (52-55): Expected primary expression.
@@ -1,8 +1,8 @@
contract C {
function f() internal pure {
var i = 31415999999999999999999999999999999999999999999999999999999999999999933**3;
var unreachable = 123;
uint i = 31415999999999999999999999999999999999999999999999999999999999999999933**3;
uint unreachable = 123;
}
}
// ----
// TypeError 6963: (62-136): Invalid rational int_const 3100...(204 digits omitted)...9237 (absolute value too large or division by zero).
// TypeError 9574: (54-137): Type int_const 3100...(204 digits omitted)...9237 is not implicitly convertible to expected type uint256. Literal is too large to fit in uint256.
@@ -1,30 +0,0 @@
contract C {
function h() internal pure returns (uint, uint, uint) {
return (1, 2, 4);
}
function g(uint x) internal pure returns (uint) {
return x;
}
function f() internal pure {
var s = -31415;
var i = 31415;
var t = "string";
var g2 = g;
var myblockhash = block.blockhash;
var (a, b) = (2, "troi");
var (x,, z) = h();
var (c, d) = ("");
var (k, l) = (2);
var (m, n) = 1;
var (o, p) = "";
}
}
// ----
// SyntaxError 1719: (224-238): Use of the "var" keyword is disallowed. Use explicit declaration `int16 s = ...´ instead.
// SyntaxError 1719: (248-261): Use of the "var" keyword is disallowed. Use explicit declaration `uint16 i = ...´ instead.
// SyntaxError 1719: (271-287): Use of the "var" keyword is disallowed. Use explicit declaration `string memory t = ...´ instead.
// SyntaxError 1719: (297-307): Use of the "var" keyword is disallowed. Use explicit declaration `function (uint256) pure returns (uint256) g2 = ...´ instead.
// SyntaxError 3478: (317-350): Use of the "var" keyword is disallowed. Type cannot be expressed in syntax.
// SyntaxError 1719: (360-384): Use of the "var" keyword is disallowed. Use explicit declaration `(uint8 a, string memory b) = ...´ instead.
// SyntaxError 1719: (394-411): Use of the "var" keyword is disallowed. Use explicit declaration `(uint256 x, , uint256 z) = ...´ instead.
// TypeError 7364: (421-438): Different number of components on the left hand side (2) than on the right hand side (1).