diff options
author | chriseth <c@ethdev.com> | 2017-01-26 20:40:40 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2017-01-26 20:40:40 +0800 |
commit | 525758a130941c6f1dfde8a0f884a550e7a7bb50 (patch) | |
tree | 34ac53364bc3aec20a9cc9d324d41721e9143687 | |
parent | f62e269115822f791a0ad2e3699815f0725a0ef7 (diff) | |
download | dexon-solidity-525758a130941c6f1dfde8a0f884a550e7a7bb50.tar.gz dexon-solidity-525758a130941c6f1dfde8a0f884a550e7a7bb50.tar.zst dexon-solidity-525758a130941c6f1dfde8a0f884a550e7a7bb50.zip |
Disallow assignment to non-identifiers.
-rw-r--r-- | libsolidity/inlineasm/AsmParser.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/InlineAssembly.cpp | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp index bed90139..7ddc6d04 100644 --- a/libsolidity/inlineasm/AsmParser.cpp +++ b/libsolidity/inlineasm/AsmParser.cpp @@ -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; diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index 9ee84867..33721bbf 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -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() } |