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

Fix deleting a value from a map. #715

Closed
jacqueswww opened this issue Mar 22, 2018 · 1 comment · Fixed by #718
Closed

Fix deleting a value from a map. #715

jacqueswww opened this issue Mar 22, 2018 · 1 comment · Fixed by #718

Comments

@jacqueswww
Copy link
Contributor

jacqueswww commented Mar 22, 2018

What's your issue about?

It seems that del keyword doesn't work for a map.

E           vyper.exceptions.StructureException: line 14: Unsupported statement type
E               del self.big_storage[key]
E           ----^

Example test case:

def test_map_delete(get_contract):
    code = """
big_storage: bytes32[bytes32]

@public
def set(key: bytes32, value: bytes32):
    self.big_storage[key] = value

@public
def get(key: bytes32) -> bytes32:
    return self.big_storage[key]

@public
def delete(key: bytes32):
    del self.big_storage[key]
    """

    c = get_contract(code)

    assert c.get("test") == b""
    assert c.set("test", "value")
    assert c.get("test") == b"value"
    c.delete("test")
    assert c.get("test") == b""

This will be done

How can it be fixed?

Fixed by using SSTORE 0x0on the sha32'ed key value.

Cute Animal Picture

@jacqueswww jacqueswww changed the title Support deleting a value from a map. Fix deleting a value from a map. Mar 22, 2018
@fubuloubu
Copy link
Member

I think this is actually good syntax for those coming from Python 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants