Skip to content

Commit

Permalink
Add support for delete operator on UDVT
Browse files Browse the repository at this point in the history
  • Loading branch information
xBA5ED committed Oct 31, 2023
1 parent ad3caa7 commit 21438dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libsolidity/ast/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2677,6 2677,11 @@ bool UserDefinedValueType::operator==(Type const& _other) const
return other.definition() == definition();
}

TypeResult UserDefinedValueType::unaryOperatorResult(Token _operator) const
{
return _operator == Token::Delete ? TypeProvider::emptyTuple() : nullptr;
}

std::string UserDefinedValueType::toString(bool /* _withoutDataLocation */) const
{
return *definition().annotation().canonicalName;
Expand Down
1 change: 1 addition & 0 deletions libsolidity/ast/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 1138,7 @@ class UserDefinedValueType: public Type
{}

Category category() const override { return Category::UserDefinedValueType; }
TypeResult unaryOperatorResult(Token _operator) const override;
Type const& underlyingType() const;
UserDefinedValueTypeDefinition const& definition() const { return m_definition; }

Expand Down
5 changes: 5 additions & 0 deletions test/libsolidity/syntaxTests/userDefinedValueType/delete.sol
Original file line number Diff line number Diff line change
@@ -0,0 1,5 @@
type MyInt is int;
function f() pure {
MyInt i = MyInt.wrap(1);
delete i;
}

0 comments on commit 21438dc

Please sign in to comment.