Added error for interface function with modifiers; test case

This commit is contained in:
hrkrshnn 2020-04-02 20:30:43 +05:30
parent 8d28089abc
commit ef2bef9ddc
2 changed files with 9 additions and 1 deletions

View File

@ -303,7 +303,9 @@ bool SyntaxChecker::visit(FunctionDefinition const& _function)
); );
} }
if (!_function.isImplemented() && !_function.modifiers().empty()) if (m_isInterface && !_function.modifiers().empty())
m_errorReporter.syntaxError(_function.location(), "Functions in interfaces cannot have modifiers.");
else if (!_function.isImplemented() && !_function.modifiers().empty())
m_errorReporter.syntaxError(_function.location(), "Functions without implementation cannot have modifiers."); m_errorReporter.syntaxError(_function.location(), "Functions without implementation cannot have modifiers.");
return true; return true;

View File

@ -0,0 +1,6 @@
interface I {
function f() external m pure returns (uint);
modifier m() { _; }
}
// ----
// SyntaxError: (16-60): Functions in interfaces cannot have modifiers.