Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions libsolidity/ast/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2680,6 +2680,11 @@ BoolResult EnumType::isExplicitlyConvertibleTo(Type const& _convertTo) const
return false;
}

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

unsigned EnumType::memberValue(ASTString const& _member) const
{
unsigned index = 0;
Expand Down
1 change: 1 addition & 0 deletions libsolidity/ast/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,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
43 changes: 43 additions & 0 deletions test/libsolidity/semanticTests/userDefinedValueType/delete.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
type MyUInt256 is uint256;
type MyBytes32 is bytes32;
type MyAddress is address;
type MyBool is bool;

contract C {
MyUInt256 a = MyUInt256.wrap(255);

function f() external returns(MyUInt256) {
delete a;
return a;
}

function g(MyUInt256 b) external returns(MyUInt256) {
delete b;
return b;
}

function h(MyAddress b) external returns(MyAddress) {
delete b;
return b;
}

function i(MyBytes32 b) external returns(MyBytes32) {
delete b;
return b;
}

function j(MyBool b) external returns(MyBool) {
delete b;
return b;
}
}
// ----
// f() -> 0
// g(uint256): 255 -> 0
// g(uint256): 0 -> 0
// h(address): 0xffffffffffffffffffffffffffffffffffffffff -> 0x0000000000000000000000000000000000000000
// h(address): 0x0000000000000000000000000000000000000000 -> 0x0000000000000000000000000000000000000000
// i(bytes32): 0xffffffffffffffffffffffffffffffffffffffff -> 0x0000000000000000000000000000000000000000
// i(bytes32): 0x0000000000000000000000000000000000000000 -> 0x0000000000000000000000000000000000000000
// j(bool): true -> false
// j(bool): false -> false