mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Changed error message and added tests
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
pragma solidity >0.4.24;
|
||||
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
do
|
||||
uint y;
|
||||
while (x > 0);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (81-87): Variable declarations can only be used inside blocks.
|
||||
@@ -0,0 +1,13 @@
|
||||
pragma solidity >0.4.24;
|
||||
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
if (x > 0)
|
||||
{uint y;}
|
||||
else
|
||||
uint z;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (109-115): Variable declarations can only be used inside blocks.
|
||||
@@ -0,0 +1,11 @@
|
||||
pragma solidity >0.4.24;
|
||||
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
for (uint i = 0; i < x; ++i)
|
||||
uint y;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (107-113): Variable declarations can only be used inside blocks.
|
||||
@@ -0,0 +1,11 @@
|
||||
pragma solidity >0.4.24;
|
||||
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
if (x > 0)
|
||||
uint y;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (89-95): Variable declarations can only be used inside blocks.
|
||||
@@ -0,0 +1,11 @@
|
||||
pragma solidity >0.4.24;
|
||||
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public pure {
|
||||
while (x > 0)
|
||||
uint y;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (92-98): Variable declarations can only be used inside blocks.
|
||||
Reference in New Issue
Block a user