-
-
Notifications
You must be signed in to change notification settings - Fork 813
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: codegen for hashmaps with string keys (#3384)
this commit fixes a regression introduced in 3abe588, where the codegen in parse_Subscript would handle string keys as non-bytestrings (thus treating the value of the string as word loaded by the string pointer - its length value). it also cleans up the logic a little bit, avoiding a redundant unwrap_location (since get_element_ptr calls unwrap_location itself), and removing a dead argument from keccak256_helper.
1 parent
5ae0a07
commit d62125c
Showing
5 changed files
with
35 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
def test_string_map_keys(get_contract): | ||
code = """ | ||
f:HashMap[String[1], bool] | ||
@external | ||
def test() -> bool: | ||
a:String[1] = "a" | ||
b:String[1] = "b" | ||
self.f[a] = True | ||
return self.f[b] # should return False | ||
""" | ||
c = get_contract(code) | ||
c.test() | ||
assert c.test() is False | ||
|
||
|
||
def test_string_map_keys_literals(get_contract): | ||
code = """ | ||
f:HashMap[String[1], bool] | ||
@external | ||
def test() -> bool: | ||
self.f["a"] = True | ||
return self.f["b"] # should return False | ||
""" | ||
c = get_contract(code) | ||
assert c.test() is False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters