Merge pull request #4306 from ethereum/remove_050_workaround_scoping

[BREAKING] C99 scoping rules by default (remove 050 workaround)
This commit is contained in:
chriseth
2018-06-21 13:57:59 +02:00
committed by GitHub
35 changed files with 85 additions and 219 deletions
+4 -2
View File
@@ -536,8 +536,9 @@ contract provider is module, safeMath, announcementTypes {
address provAddr;
uint256 provHeight;
bool interest = false;
uint256 a;
var rate = clients[msg.sender].lastRate;
for ( uint256 a = (clients[msg.sender].paidUpTo + 1) ; a <= currentSchellingRound ; a++ ) {
for ( a = (clients[msg.sender].paidUpTo + 1) ; a <= currentSchellingRound ; a++ ) {
if (globalFunds[a].reward > 0 && globalFunds[a].supply > 0) {
provAddr = clients[msg.sender].providerAddress;
provHeight = clients[msg.sender].providerHeight;
@@ -585,8 +586,9 @@ contract provider is module, safeMath, announcementTypes {
uint256 steps;
uint256 currHeight = providers[addr].currentHeight;
uint256 LTSID = providers[addr].data[currHeight].lastSupplyID;
uint256 a;
var rate = providers[addr].data[currHeight].lastPaidRate;
for ( uint256 a = (providers[addr].data[currHeight].paidUpTo + 1) ; a <= currentSchellingRound ; a++ ) {
for ( a = (providers[addr].data[currHeight].paidUpTo + 1) ; a <= currentSchellingRound ; a++ ) {
if (globalFunds[a].reward > 0 && globalFunds[a].supply > 0) {
if ( providers[addr].data[currHeight].rateHistory[a].valid ) {
rate = providers[addr].data[currHeight].rateHistory[a].value;
@@ -155,7 +155,8 @@ library strings {
// Starting at ptr-31 means the LSB will be the byte we care about
var ptr = self._ptr - 31;
var end = ptr + self._len;
for (uint len = 0; ptr < end; len++) {
uint len;
for (len = 0; ptr < end; len++) {
uint8 b;
assembly { b := and(mload(ptr), 0xFF) }
if (b < 0x80) {
@@ -695,7 +696,7 @@ library strings {
uint retptr;
assembly { retptr := add(ret, 32) }
for(i = 0; i < parts.length; i++) {
for(uint i = 0; i < parts.length; i++) {
memcpy(retptr, parts[i]._ptr, parts[i]._len);
retptr += parts[i]._len;
if (i < parts.length - 1) {
-16
View File
@@ -133,22 +133,6 @@ BOOST_AUTO_TEST_CASE(assignment_in_declaration)
CHECK_SUCCESS_NO_WARNINGS(text);
}
BOOST_AUTO_TEST_CASE(use_before_declaration)
{
string text = R"(
contract C {
function f() public pure { a = 3; uint a = 2; assert(a == 2); }
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
text = R"(
contract C {
function f() public pure { assert(a == 0); uint a = 2; assert(a == 2); }
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
}
BOOST_AUTO_TEST_CASE(function_call_does_not_clear_local_vars)
{
string text = R"(
+1 -1
View File
@@ -5011,7 +5011,7 @@ BOOST_AUTO_TEST_CASE(byte_array_push_transition)
if (data.length != i) return 0x1000 + i;
if (data[data.length - 1] != byte(i)) return i;
}
for (i = 1; i < 40; i++)
for (uint8 i = 1; i < 40; i++)
if (data[i - 1] != byte(i)) return 0x1000000 + i;
return 0;
}
@@ -1,8 +1,9 @@
contract test {
function f() pure public {
uint256 x;
if (true) { uint256 x; }
x = 1;
if (true) { uint256 x; x = 2; }
}
}
// ----
// DeclarationError: (71-80): Identifier already declared.
// Warning: (80-89): This declaration shadows an existing declaration.
@@ -1,11 +0,0 @@
pragma experimental "v0.5.0";
contract test {
function f() pure public {
uint256 x;
if (true) { uint256 x; }
}
}
// ----
// Warning: (101-110): This declaration shadows an existing declaration.
// Warning: (76-85): Unused local variable.
// Warning: (101-110): Unused local variable.
@@ -2,3 +2,5 @@ contract B {
function f() mod(x) pure public { uint x = 7; }
modifier mod(uint a) { if (a > 0) _; }
}
// ----
// DeclarationError: (34-35): Undeclared identifier.
@@ -1,7 +0,0 @@
pragma experimental "v0.5.0";
contract B {
function f() mod(x) pure public { uint x = 7; }
modifier mod(uint a) { if (a > 0) _; }
}
// ----
// DeclarationError: (64-65): Undeclared identifier.
@@ -1,5 +1,3 @@
pragma experimental "v0.5.0";
contract C {
function f() internal {
{
@@ -9,4 +7,4 @@ contract C {
}
}
// ----
// DeclarationError: (130-131): Undeclared identifier.
// DeclarationError: (99-100): Undeclared identifier.
@@ -1,5 +1,3 @@
pragma experimental "v0.5.0";
contract C {
function f() internal {
{
@@ -8,6 +6,6 @@ contract C {
}
}
// ----
// DeclarationError: (110-111): Undeclared identifier. Did you mean "a"?
// DeclarationError: (113-114): Undeclared identifier. Did you mean "b"?
// DeclarationError: (116-117): Undeclared identifier. Did you mean "c"?
// DeclarationError: (79-80): Undeclared identifier. "a" is not (or not yet) visible at this point.
// DeclarationError: (82-83): Undeclared identifier. "b" is not (or not yet) visible at this point.
// DeclarationError: (85-86): Undeclared identifier. "c" is not (or not yet) visible at this point.
@@ -3,4 +3,4 @@ contract c {
function g() public { f(); }
}
// ----
// DeclarationError: (68-69): Undeclared identifier. Did you mean "f"?
// DeclarationError: (68-69): Undeclared identifier. "f" is not (or not yet) visible at this point.
@@ -1,6 +0,0 @@
contract C {
function f() pure public {
a = 7;
uint a;
}
}
@@ -1,11 +1,8 @@
contract A {
function f() {
function f() public pure {
uint y = 1;
uint x = 3 < 0 ? x = 3 : 6;
uint x = 3 < 0 ? y = 3 : 6;
true ? x = 3 : 4;
}
}
// ----
// Warning: (17-119): No visibility specified. Defaulting to "public".
// Warning: (40-46): Unused local variable.
// Warning: (17-119): Function state mutability can be restricted to pure
@@ -1,9 +1,7 @@
contract test {
function fun(uint256 a) {
while (true) { uint256 x = 1; break; continue; } x = 9;
function fun() public pure {
uint256 x;
while (true) { x = 1; break; continue; } x = 9;
}
}
// ----
// Warning: (20-115): No visibility specified. Defaulting to "public".
// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (20-115): Function state mutability can be restricted to pure
@@ -5,4 +5,5 @@ contract test {
}
}
// ----
// DeclarationError: (77-83): Identifier already declared.
// Warning: (57-63): Unused local variable.
// Warning: (77-83): Unused local variable.
@@ -1,10 +0,0 @@
pragma experimental "v0.5.0";
contract test {
function f() pure public {
{ uint x; }
{ uint x; }
}
}
// ----
// Warning: (87-93): Unused local variable.
// Warning: (107-113): Unused local variable.
@@ -5,4 +5,5 @@ contract test {
}
}
// ----
// DeclarationError: (75-81): Identifier already declared.
// Warning: (57-63): Unused local variable.
// Warning: (75-81): Unused local variable.
@@ -1,10 +0,0 @@
pragma experimental "v0.5.0";
contract test {
function f() pure public {
{ uint x; }
uint x;
}
}
// ----
// Warning: (87-93): Unused local variable.
// Warning: (105-111): Unused local variable.
@@ -1,4 +1,3 @@
pragma experimental "v0.5.0";
contract test {
function f() public {
{
@@ -8,4 +7,4 @@ contract test {
}
}
// ----
// DeclarationError: (123-124): Undeclared identifier.
// DeclarationError: (93-94): Undeclared identifier.
@@ -1,4 +1,3 @@
pragma experimental "v0.5.0";
contract test {
function f() pure public {
x = 3;
@@ -6,4 +5,4 @@ contract test {
}
}
// ----
// DeclarationError: (85-86): Undeclared identifier. Did you mean "x"?
// DeclarationError: (55-56): Undeclared identifier. "x" is not (or not yet) visible at this point.
@@ -4,3 +4,5 @@ contract test {
uint x;
}
}
// ----
// DeclarationError: (55-56): Undeclared identifier. "x" is not (or not yet) visible at this point.
@@ -1,4 +1,3 @@
pragma experimental "v0.5.0";
contract test {
function f() pure public {
for (uint x = 0; x < 10; x ++){
@@ -1,4 +1,3 @@
pragma experimental "v0.5.0";
contract test {
function f() pure public {
for (uint x = 0; x < 10; x ++)
@@ -1,4 +1,3 @@
pragma experimental "v0.5.0";
contract test {
function f() pure public {
for (uint x = 0; x < 10; x ++){
@@ -8,4 +7,4 @@ contract test {
}
}
// ----
// DeclarationError: (154-155): Undeclared identifier.
// DeclarationError: (124-125): Undeclared identifier.
@@ -1,4 +1,3 @@
pragma experimental "v0.5.0";
contract test {
function f() pure public {
for (;; y++){
@@ -7,4 +6,4 @@ contract test {
}
}
// ----
// DeclarationError: (93-94): Undeclared identifier.
// DeclarationError: (63-64): Undeclared identifier.
@@ -4,3 +4,5 @@ contract test {
uint256 x = 2;
}
}
// ----
// DeclarationError: (55-56): Undeclared identifier. "x" is not (or not yet) visible at this point.
@@ -3,3 +3,5 @@ contract test {
uint a = a;
}
}
// ----
// DeclarationError: (64-65): Undeclared identifier. "a" is not (or not yet) visible at this point.
@@ -1,8 +0,0 @@
pragma experimental "v0.5.0";
contract test {
function f() pure public {
uint a = a;
}
}
// ----
// DeclarationError: (94-95): Undeclared identifier. Did you mean "a"?