fixup! Syntax for custom errors.

This commit is contained in:
chriseth
2021-02-02 16:31:36 +01:00
parent edf3529db6
commit b6183edd18
4 changed files with 16 additions and 0 deletions
+11
View File
@@ -192,6 +192,17 @@ void SyntaxChecker::endVisit(ModifierDefinition const& _modifier)
m_placeholderFound = false;
}
bool SyntaxChecker::visit(ErrorDefinition const& _error)
{
if (_error.name() == "Error" || _error.name() == "Panic")
m_errorReporter.syntaxError(
1855_error,
_error.location(),
"The built-in errors \"Error\" and \"Panic\" cannot be re-defined."
);
return true;
}
void SyntaxChecker::checkSingleStatementVariableDeclaration(ASTNode const& _statement)
{
auto varDecl = dynamic_cast<VariableDeclarationStatement const*>(&_statement);
+3
View File
@@ -40,6 +40,7 @@ namespace solidity::frontend
* - issues deprecation warning for throw
* - whether the msize instruction is used and the Yul optimizer is enabled at the same time.
* - selection of the ABI coder through pragmas.
* - whether user-defined errors are called Error or Panic.
*/
class SyntaxChecker: private ASTConstVisitor
{
@@ -61,6 +62,8 @@ private:
bool visit(ModifierDefinition const& _modifier) override;
void endVisit(ModifierDefinition const& _modifier) override;
bool visit(ErrorDefinition const& _error) override;
/// Reports an error if _statement is a VariableDeclarationStatement.
/// Used by if/while/for to check for single statement variable declarations
/// without a block.