From 56fe3a6ab93116438ea52634e891c71b995d7c3f Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 24 May 2017 13:13:05 +0100 Subject: [PATCH] Better error messages during parsing functional instructions --- Changelog.md | 4 ++++ libsolidity/inlineasm/AsmParser.cpp | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/Changelog.md b/Changelog.md index 2073c0a4efdb..5ba712f53496 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ ### 0.4.12 (unreleased) + +Features: * AST: export all attributes to Json format + * Inline Assembly: Present proper error message when not supplying enough arguments to a functional + instruction. Bugfixes: * Unused variable warnings no longer issued for variables used inside inline assembly diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp index 85ae94241f19..519bfa2eb83f 100644 --- a/libsolidity/inlineasm/AsmParser.cpp +++ b/libsolidity/inlineasm/AsmParser.cpp @@ -321,6 +321,15 @@ assembly::Statement Parser::parseCall(assembly::Statement&& _instruction) unsigned args = unsigned(instrInfo.args); for (unsigned i = 0; i < args; ++i) { + /// check for premature closing parentheses + if (m_scanner->currentToken() == Token::RParen) + fatalParserError(string( + "Expected " + + boost::lexical_cast(args) + + " arguments, but received " + + boost::lexical_cast(i) + )); + ret.arguments.emplace_back(parseExpression()); if (i != args - 1) {