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
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
Prev Previous commit
Next Next commit
test: add semantic test for UDVT delete operator
  • Loading branch information
xBA5ED committed Oct 31, 2023
commit 39e7491b3877f9d6ba4d523c5edcd33c9ef1933c
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