-
-
Notifications
You must be signed in to change notification settings - Fork 814
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
chore: improve error message for bytestring length check #3313
chore: improve error message for bytestring length check #3313
Conversation
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## master #3313 +/- ##
==========================================
- Coverage 88.93% 88.76% -0.17%
==========================================
Files 84 85 +1
Lines 10606 10711 +105
Branches 2216 2234 +18
==========================================
+ Hits 9432 9508 +76
- Misses 768 802 +34
+ Partials 406 401 -5
... and 41 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
valid_list = [ | ||
""" | ||
@external | ||
def foo() -> String[10]: | ||
return "badminton" | ||
""", | ||
""" | ||
@external | ||
def foo(): | ||
x: String[11] = "¡très bien!" | ||
""", | ||
""" | ||
@external | ||
def test() -> String[100]: | ||
return "hello world!" | ||
""", | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated tests:
vyper/tests/parser/syntax/test_string.py
Lines 5 to 15 in a5995a9
valid_list = [ | |
""" | |
@external | |
def foo() -> String[10]: | |
return "badminton" | |
""", | |
""" | |
@external | |
def foo(): | |
x: String[11] = "¡très bien!" | |
""", |
I moved the last example to this file.
What I did
The following invalid syntax runs into an error when raising an exception - (and similarly for
Bytes[N]
):This should have been caught here:
vyper/vyper/semantics/types/bytestrings.py
Lines 125 to 129 in a5995a9
Additionally, the error message for
DynArray
andHashMap
can be improved:This compiles when it should raise:
How I did it
Call
from_annotation
for its side effects intype_from_annotation
if the attribute exists for the retrieved type.How to verify it
See tests.
Commit message
Description for the changelog
Improve error message for bytestring length check
Cute Animal Picture