Disallow assignment to non-identifiers.

This commit is contained in:
chriseth 2017-01-26 13:40:40 +01:00
parent f62e269115
commit 525758a130
2 changed files with 8 additions and 0 deletions

View File

@ -71,6 +71,8 @@ assembly::Statement Parser::parseStatement()
expectToken(Token::Colon);
assignment.variableName.location = location();
assignment.variableName.name = m_scanner->currentLiteral();
if (instructions().count(assignment.variableName.name))
fatalParserError("Identifier expected.");
assignment.location.end = endPosition();
expectToken(Token::Identifier);
return assignment;

View File

@ -194,6 +194,12 @@ BOOST_AUTO_TEST_CASE(inline_assembly_shadowed_instruction_assignment)
BOOST_CHECK(!successAssemble("{ 2 =: gas }"));
}
BOOST_AUTO_TEST_CASE(inline_assembly_shadowed_instruction_functional_assignment)
{
// Error message: "Cannot use instruction names for identifier names."
BOOST_CHECK(!successAssemble("{ gas := 2 }"));
}
BOOST_AUTO_TEST_SUITE_END()
}