mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
fixup! Syntax for custom errors.
This commit is contained in:
parent
edf3529db6
commit
b6183edd18
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -1,3 +1,4 @@
|
||||
// TODO do we want to disallow this at all?
|
||||
error Error(uint);
|
||||
// ----
|
||||
// SyntaxError 1855: (44-62): The built-in errors "Error" and "Panic" cannot be re-defined.
|
||||
|
@ -2,3 +2,4 @@
|
||||
// TODO I Think the best way would be to have Error in the global scope.
|
||||
error Panic(bytes2);
|
||||
// ----
|
||||
// SyntaxError 1855: (131-151): The built-in errors "Error" and "Panic" cannot be re-defined.
|
||||
|
Loading…
Reference in New Issue
Block a user