OperationAnnotation::userDefinedFunction can be set only once

This commit is contained in:
wechman
2022-09-28 13:09:13 +02:00
parent 59c8ec0e65
commit c507d24a78
8 changed files with 40 additions and 24 deletions
@@ -673,11 +673,13 @@ bool IRGeneratorForStatements::visit(UnaryOperation const& _unaryOperation)
{
setLocation(_unaryOperation);
if (FunctionDefinition const* function = _unaryOperation.annotation().userDefinedFunction)
if (_unaryOperation.annotation().userDefinedFunction.set())
{
_unaryOperation.subExpression().accept(*this);
setLocation(_unaryOperation);
FunctionDefinition const* function = *_unaryOperation.annotation().userDefinedFunction;
solAssert(function);
solAssert(
function->isFree() || function->libraryFunction(),
"Only file-level functions and library functions can be bound to a user type operator."
@@ -817,12 +819,14 @@ bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp)
{
setLocation(_binOp);
if (FunctionDefinition const* function = _binOp.annotation().userDefinedFunction)
if (_binOp.annotation().userDefinedFunction.set())
{
_binOp.leftExpression().accept(*this);
_binOp.rightExpression().accept(*this);
setLocation(_binOp);
FunctionDefinition const* function = *_binOp.annotation().userDefinedFunction;
solAssert(function);
solAssert(
function->isFree() || function->libraryFunction(),
"Only file-level functions and library functions can be bound to a user type operator."