Merge pull request #8585 from ethereum/virtual-library-function

Added error message for virtual (library) functions; test case
This commit is contained in:
Daniel Kirchner 2020-04-03 13:29:29 +02:00 committed by GitHub
commit a1b28953a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 1 deletions

View File

@ -21,6 +21,7 @@ Bugfixes:
* Inline Assembly: Fix internal error when accessing incorrect constant variables.
* Inheritance: Allow public state variables to override functions with dynamic memory types in their return values.
* JSON AST: Always add pointer suffix for memory reference types.
* Type Checker: Disallow virtual for library functions.
### 0.6.4 (2020-03-10)

View File

@ -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())

View File

@ -177,7 +177,6 @@ library Math {
/// @param nums Numbers to look through
/// @return max Maximum number
function max(int[] memory nums)
virtual
public
pure
returns (int max)

View File

@ -0,0 +1,5 @@
library L {
function f() internal pure virtual returns (uint) { return 0; }
}
// ----
// TypeError: (16-79): Library functions cannot be "virtual".