mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Library function can be used as user operator
This commit is contained in:
@@ -413,7 +413,10 @@ bool ExpressionCompiler::visit(UnaryOperation const& _unaryOperation)
|
||||
|
||||
if (FunctionDefinition const* function = _unaryOperation.annotation().userDefinedFunction)
|
||||
{
|
||||
solAssert(function->isFree(), "Only free functions can be bound to a user type operator.");
|
||||
solAssert(
|
||||
function->isFree() || function->libraryFunction(),
|
||||
"Only file-level functions and library functions can be bound to a user type operator."
|
||||
);
|
||||
|
||||
FunctionType const* functionType = dynamic_cast<FunctionType const*>(
|
||||
function->libraryFunction() ? function->typeViaContractName() : function->type()
|
||||
@@ -537,7 +540,10 @@ bool ExpressionCompiler::visit(BinaryOperation const& _binaryOperation)
|
||||
Expression const& rightExpression = _binaryOperation.rightExpression();
|
||||
if (FunctionDefinition const* function =_binaryOperation.annotation().userDefinedFunction)
|
||||
{
|
||||
solAssert(function->isFree(), "Only free function can be bound to a user type operator.");
|
||||
solAssert(
|
||||
function->isFree() || function->libraryFunction(),
|
||||
"Only file-level functions and library functions can be bound to a user type operator."
|
||||
);
|
||||
FunctionType const* functionType = dynamic_cast<FunctionType const*>(
|
||||
function->libraryFunction() ? function->typeViaContractName() : function->type()
|
||||
);
|
||||
|
||||
@@ -679,7 +679,7 @@ bool IRGeneratorForStatements::visit(UnaryOperation const& _unaryOperation)
|
||||
setLocation(_unaryOperation);
|
||||
|
||||
solAssert(
|
||||
dynamic_cast<SourceUnit const*>(function->scope()),
|
||||
function->isFree() || function->libraryFunction(),
|
||||
"Only file-level functions and library functions can be bound to a user type operator."
|
||||
);
|
||||
|
||||
@@ -824,7 +824,7 @@ bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp)
|
||||
setLocation(_binOp);
|
||||
|
||||
solAssert(
|
||||
dynamic_cast<SourceUnit const*>(function->scope()),
|
||||
function->isFree() || function->libraryFunction(),
|
||||
"Only file-level functions and library functions can be bound to a user type operator."
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user