diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 1345fbf90..9ddc766b8 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -332,6 +332,8 @@ bool TypeChecker::visit(FunctionDefinition const& _function) m_errorReporter.warning(_function.location(), "Interface functions are implicitly \"virtual\""); if (_function.visibility() == Visibility::Private) m_errorReporter.typeError(_function.location(), "\"virtual\" and \"private\" cannot be used together."); + if (isLibraryFunction) + m_errorReporter.typeError(_function.location(), "Library functions cannot be \"virtual\"."); } if (_function.isPayable()) diff --git a/test/libsolidity/syntaxTests/inheritance/virtual/library_err.sol b/test/libsolidity/syntaxTests/inheritance/virtual/library_err.sol new file mode 100644 index 000000000..627be82ff --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/virtual/library_err.sol @@ -0,0 +1,5 @@ +library L { + function f() internal pure virtual returns (uint) { return 0; } +} +// ---- +// TypeError: (16-79): Library functions cannot be "virtual".