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

Fixes for bytearrays as hashmap key #2239

Merged
merged 3 commits into from Dec 3, 2020

Conversation

iamdefinitelyahuman
Copy link
Contributor

What I did

Fix two compile-time issues related to bytearray types as HashMap keys:

  • bytearrays that are part of a struct
  • bytearrays in storage

Closes #2237

How I did it

  1. In vyper/parser/parser_utils.py, do not assume that the key is a memory offset. This allows the use of structs.
  2. In vyper/parser/expr.py, add a special case when the key is a bytearray in storage. Because sha3 only works on memory, we must first copy the bytearray to memory.

How to verify it

Run the tests. I've added several new cases to target this (and related) behavior.

Cute Animal Picture

image

@codecov-io
Copy link

codecov-io commented Dec 3, 2020

Codecov Report

Merging #2239 (c300fd8) into master (1a58196) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2239      +/-   ##
==========================================
+ Coverage   85.37%   85.38%   +0.01%     
==========================================
  Files          84       84              
  Lines        8566     8574       +8     
  Branches     2072     2074       +2     
==========================================
+ Hits         7313     7321       +8     
  Misses        746      746              
  Partials      507      507              
Impacted Files Coverage Δ
vyper/parser/expr.py 77.82% <100.00%> (+0.22%) ⬆️
vyper/parser/parser_utils.py 81.42% <100.00%> (+0.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a58196...c300fd8. Read the comment docs.

@fubuloubu fubuloubu merged commit 9b88d77 into vyperlang:master Dec 3, 2020
@iamdefinitelyahuman iamdefinitelyahuman deleted the fix-hashmaps branch December 4, 2020 10:32
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 this pull request may close these issues.

CompilerPanic caused by using String[64] directly as HashMap key
3 participants