Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for delete operator on UDVT #14633

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add support for delete operator on UDVT
  • Loading branch information
xBA5ED committed Oct 19, 2023
commit 34496ca8c3ca8bbdf50f4625ead766d5fdeed63e
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;
}