From 2530223ab5c470c01b7e684f33e1fdfa5f5f9590 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 18 Sep 2017 14:47:46 +0200 Subject: More verbose errors for generated assembly. --- libsolidity/codegen/CompilerContext.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'libsolidity') diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index 5a77162e..d87c7be5 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -312,8 +313,23 @@ void CompilerContext::appendInlineAssembly( ErrorReporter errorReporter(errors); auto scanner = make_shared(CharStream(_assembly), "--CODEGEN--"); auto parserResult = assembly::Parser(errorReporter).parse(scanner); - solAssert(parserResult, "Failed to parse inline assembly block."); - solAssert(errorReporter.errors().empty(), "Failed to parse inline assembly block."); + if (!parserResult || !errorReporter.errors().empty()) + { + string message = + "Error parsing inline assembly block:\n" + "------------------ Input: -----------------\n" + + _assembly + "\n" + "------------------ Errors: ----------------\n"; + for (auto const& error: errorReporter.errors()) + message += SourceReferenceFormatter::formatExceptionInformation( + *error, + (error->type() == Error::Type::Warning) ? "Warning" : "Error", + [&](string const&) -> Scanner const& { return *scanner; } + ); + message += "-------------------------------------------\n"; + + solAssert(false, message); + } assembly::AsmAnalysisInfo analysisInfo; assembly::AsmAnalyzer analyzer(analysisInfo, errorReporter, false, identifierAccess.resolve); -- cgit v1.2.3