mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
add another test case for continue not in loop
This commit is contained in:
parent
c8886ed5cf
commit
df728581ce
@ -40,24 +40,24 @@ void SyntaxChecker::syntaxError(SourceLocation const& _location, std::string con
|
|||||||
m_errors.push_back(err);
|
m_errors.push_back(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SyntaxChecker::visit(WhileStatement const& _whileStatement)
|
bool SyntaxChecker::visit(WhileStatement const&)
|
||||||
{
|
{
|
||||||
m_inLoopDepth++;
|
m_inLoopDepth++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyntaxChecker::endVisit(WhileStatement const& _whileStatement)
|
void SyntaxChecker::endVisit(WhileStatement const&)
|
||||||
{
|
{
|
||||||
m_inLoopDepth--;
|
m_inLoopDepth--;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SyntaxChecker::visit(ForStatement const& _forStatement)
|
bool SyntaxChecker::visit(ForStatement const&)
|
||||||
{
|
{
|
||||||
m_inLoopDepth++;
|
m_inLoopDepth++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyntaxChecker::endVisit(ForStatement const& _forStatement)
|
void SyntaxChecker::endVisit(ForStatement const&)
|
||||||
{
|
{
|
||||||
m_inLoopDepth--;
|
m_inLoopDepth--;
|
||||||
}
|
}
|
||||||
|
@ -2934,6 +2934,21 @@ BOOST_AUTO_TEST_CASE(continue_not_in_loop)
|
|||||||
BOOST_CHECK(expectError(text) == Error::Type::SyntaxError);
|
BOOST_CHECK(expectError(text) == Error::Type::SyntaxError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(continue_not_in_loop_2)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract C {
|
||||||
|
function f() {
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(expectError(text) == Error::Type::SyntaxError);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user