Use quote function for all errors/warnings

This commit is contained in:
Mathias Baumann
2020-01-08 16:12:06 +01:00
parent 70a2902714
commit 593e2515e7
494 changed files with 1201 additions and 1157 deletions
+14 -14
View File
@@ -127,7 +127,7 @@ bool AsmAnalyzer::operator()(Identifier const& _identifier)
{
m_errorReporter.declarationError(
_identifier.location,
"Variable " + _identifier.name.str() + " used before it was declared."
"Variable" + quoteSpace(_identifier.name.str()) + "used before it was declared."
);
success = false;
}
@@ -141,7 +141,7 @@ bool AsmAnalyzer::operator()(Identifier const& _identifier)
{
m_errorReporter.typeError(
_identifier.location,
"Function " + _identifier.name.str() + " used without being called."
"Function" + quoteSpace(_identifier.name.str()) + "used without being called."
);
success = false;
}
@@ -180,7 +180,7 @@ bool AsmAnalyzer::operator()(ExpressionStatement const& _statement)
to_string(m_stackHeight - initialStackHeight) +
" value" +
(m_stackHeight - initialStackHeight == 1 ? "" : "s") +
"). Use ``pop()`` or assign them.";
"). Use" + quoteSpace("pop()") + "or assign them.";
m_errorReporter.error(Error::Type::TypeError, _statement.location, msg);
success = false;
}
@@ -350,7 +350,7 @@ bool AsmAnalyzer::operator()(FunctionCall const& _funCall)
else if (!m_dataNames.count(std::get<Literal>(arg).value))
m_errorReporter.typeError(
_funCall.functionName.location,
"Unknown data object \"" + std::get<Literal>(arg).value.str() + "\"."
"Unknown data object " + quote(std::get<Literal>(arg).value.str()) + "."
);
}
}
@@ -558,7 +558,7 @@ bool AsmAnalyzer::expectDeposit(int _deposit, int _oldHeight, SourceLocation con
{
m_errorReporter.typeError(
_location,
"Expected expression to return one item to the stack, but did return " +
"Expected expression to return one item to the stack, but it returned " +
to_string(m_stackHeight - _oldHeight) +
" items."
);
@@ -585,7 +585,7 @@ bool AsmAnalyzer::checkAssignment(Identifier const& _variable, size_t _valueSize
{
m_errorReporter.declarationError(
_variable.location,
"Variable " + _variable.name.str() + " used before it was declared."
"Variable" + quoteSpace(_variable.name.str()) + "used before it was declared."
);
success = false;
}
@@ -638,7 +638,7 @@ void AsmAnalyzer::expectValidType(string const& type, SourceLocation const& _loc
if (!builtinTypes.count(type))
m_errorReporter.typeError(
_location,
"\"" + type + "\" is not a valid type (user defined types are not yet supported)."
quote(type) + " is not a valid type (user defined types are not yet supported)."
);
}
@@ -663,14 +663,14 @@ bool AsmAnalyzer::warnOnInstructions(evmasm::Instruction _instr, SourceLocation
auto errorForVM = [=](string const& vmKindMessage) {
m_errorReporter.typeError(
_location,
"The \"" +
boost::to_lower_copy(instructionInfo(_instr).name)
+ "\" instruction is " +
"The" +
quoteSpace(boost::to_lower_copy(instructionInfo(_instr).name))
+ "instruction is " +
vmKindMessage +
" VMs " +
" (you are currently compiling for \"" +
m_evmVersion.name() +
"\")."
" (you are currently compiling for " +
quote(m_evmVersion.name()) +
")."
);
};
@@ -720,7 +720,7 @@ bool AsmAnalyzer::warnOnInstructions(evmasm::Instruction _instr, SourceLocation
_location,
"Jump instructions and labels are low-level EVM features that can lead to "
"incorrect stack access. Because of that they are disallowed in strict assembly. "
"Use functions, \"switch\", \"if\" or \"for\" statements instead."
"Use functions, " + quote("switch") + "," + quoteSpace("if") + "or" + quoteSpace("for") + "statements instead."
);
}
else
+10 -11
View File
@@ -151,7 +151,7 @@ Statement Parser::parseStatement()
{
Statement stmt{createWithLocation<Leave>()};
if (!m_insideFunction)
m_errorReporter.syntaxError(location(), "Keyword \"leave\" can only be used inside a function.");
m_errorReporter.syntaxError(location(), "Keyword" + quoteSpace("leave") + "can only be used inside a function.");
m_scanner->next();
return stmt;
}
@@ -184,17 +184,16 @@ Statement Parser::parseStatement()
auto const token = currentToken() == Token::Comma ? "," : ":=";
fatalParserError(
std::string("Variable name must precede \"") +
token +
"\"" +
(currentToken() == Token::Comma ? " in multiple assignment." : " in assignment.")
std::string("Variable name must precede") +
quoteSpace(token) +
(currentToken() == Token::Comma ? "in multiple assignment." : "in assignment.")
);
}
auto const& identifier = std::get<Identifier>(elementary);
if (m_dialect.builtin(identifier.name))
fatalParserError("Cannot assign to builtin function \"" + identifier.name.str() + "\".");
fatalParserError("Cannot assign to builtin function " + quoteSpace(identifier.name.str()) + ".");
variableNames.emplace_back(identifier);
@@ -477,7 +476,7 @@ Expression Parser::parseCall(Parser::ElementaryOperation&& _initialOp)
fatalParserError(
m_dialect.flavour == AsmFlavour::Yul ?
"Function name expected." :
"Assembly instruction or function name required in front of \"(\")"
"Assembly instruction or function name required in front of " + quoteSpace("()") + "."
);
expectToken(Token::LParen);
@@ -526,7 +525,7 @@ YulString Parser::expectAsmIdentifier()
}
if (m_dialect.builtin(name))
fatalParserError("Cannot use builtin function name \"" + name.str() + "\" as identifier name.");
fatalParserError("Cannot use builtin function name" + quoteSpace(name.str()) + "as identifier name.");
advance();
return name;
}
@@ -536,13 +535,13 @@ void Parser::checkBreakContinuePosition(string const& _which)
switch (m_currentForLoopComponent)
{
case ForLoopComponent::None:
m_errorReporter.syntaxError(location(), "Keyword \"" + _which + "\" needs to be inside a for-loop body.");
m_errorReporter.syntaxError(location(), "Keyword" + quoteSpace(_which) + "needs to be inside a for-loop body.");
break;
case ForLoopComponent::ForLoopPre:
m_errorReporter.syntaxError(location(), "Keyword \"" + _which + "\" in for-loop init block is not allowed.");
m_errorReporter.syntaxError(location(), "Keyword" + quoteSpace(_which) + "in for-loop init block is not allowed.");
break;
case ForLoopComponent::ForLoopPost:
m_errorReporter.syntaxError(location(), "Keyword \"" + _which + "\" in for-loop post block is not allowed.");
m_errorReporter.syntaxError(location(), "Keyword" + quoteSpace(_which) + "in for-loop post block is not allowed.");
break;
case ForLoopComponent::ForLoopBody:
break;
+2 -2
View File
@@ -142,7 +142,7 @@ bool ScopeFiller::registerVariable(TypedName const& _name, SourceLocation const&
//@TODO secondary location
m_errorReporter.declarationError(
_location,
"Variable name " + _name.name.str() + " already taken in this scope."
"Variable name" + quoteSpace(_name.name.str()) + "already taken in this scope."
);
return false;
}
@@ -162,7 +162,7 @@ bool ScopeFiller::registerFunction(FunctionDefinition const& _funDef)
//@TODO secondary location
m_errorReporter.declarationError(
_funDef.location,
"Function name " + _funDef.name.str() + " already taken in this scope."
"Function name" + quoteSpace(_funDef.name.str()) + "already taken in this scope."
);
return false;
}