fix[parser]: fix bad tokenization of hex strings#4406
fix[parser]: fix bad tokenization of hex strings#4406charles-cooper merged 14 commits intovyperlang:masterfrom
Conversation
this commit fixes parsing of hex strings. it leaves the locations unmodified as to minimize the changes to locations in the source code
632284e to
dc593d9
Compare
|
please add tests for all 3 error cases as they are listed in #4405 |
|
not very informative: def test() -> Bytes[10]:
a: Bytes[10] = x'gloglo'
return a |
|
crashes on our grammar: def test_hexstring(get_contract):
src = """
@external
def test() -> Bytes[10]:
a: Bytes[10] = x \
'baba'
return a
"""
c = get_contract(src)
assert c.test() == b'\xba\xba' |
|
what about we pop the hex_string_location in parse and assert at the end that the locations are empty? as a sanity check to prevent confusion between str and hexbytes |
|
questionable, but maybe ok.. this compiles def test() -> Bytes[10]:
x: Bytes[10] = x' 10 '
return x |
good idea, added here 24bb91d |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4406 +/- ##
===========================================
- Coverage 91.86% 44.91% -46.96%
===========================================
Files 119 119
Lines 16640 16677 +37
Branches 2801 2806 +5
===========================================
- Hits 15286 7490 -7796
- Misses 929 8623 +7694
- Partials 425 564 +139 ☔ View full report in Codecov by Sentry. |
i'd say even if this is an issue, it's out of scope because it's not related to the tokenization changes in this PR |
this commit fixes parsing of hex strings. it leaves the locations unmodified as to minimize the changes to locations in the source code
What I did
Fix #4405
How I did it
How to verify it
Commit message
Description for the changelog
Cute Animal Picture