-
-
Notifications
You must be signed in to change notification settings - Fork 836
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[ux]: remove side effects in compare_type
for bytestrings
#3379
base: master
Are you sure you want to change the base?
Conversation
compare_type
for bytestringscompare_type
for bytestrings
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3379 +/- ##
==========================================
- Coverage 92.06% 92.04% -0.02%
==========================================
Files 120 120
Lines 17329 17319 -10
Branches 2932 2930 -2
==========================================
- Hits 15954 15942 -12
- Misses 957 958 +1
- Partials 418 419 +1 ☔ View full report in Codecov by Sentry. |
Last failing test may be resolved by #3375 |
i'm not sure it's such an easy fix. the original intent of this implementation (as far as i can tell) is to deal with progressive widening of abi types. for instance, import jsonabi as SomeInterface # say one function t() which returns `bytes`
...
@external
def foo():
x: Bytes[9] = SomeInterface.t() # t.return_type.min_length is 9
y: Bytes[10] = SomeInterface.t() # t.return_type.min_length is now 10 |
I have added this to the test cases. From what I understand, the changes made to The only other corner case is with JSON ABI imports, and other than the need to override the initial 0-length |
i see. in that case we may be able to simplify the whole min_length thing in the type. |
I think vyper/vyper/builtins/functions.py Lines 311 to 329 in 9cc56b6
Should I do it here or in a follow-up PR? |
Is this a duplicate of charles-cooper#17 and/or charles-cooper#18? |
Yes, it does look like they are addressing the same issue. |
…bytestring_compare_type
compare_type
for bytestringscompare_type
for bytestrings
…g/vyper into fix/bytestring_compare_type
…bytestring_compare_type
What I did
Removed side effects in
_Bytestring.compare_type()
.How I did it
The implementation of
compare_type
for bytestrings are now simplified to match the top-level definition ofcompare_type
:compare_type should have the meaning: "an expr of type <other> can be assigned to an expr of type <self>."
.For interface functions that return bytestring types and are imported via JSON, the bytestring types are initialized to zero. To make these functions identifiable, a
returns_abi_bytestring
attribute is added toFunctionDef
types. Now, when these JSON-imported functions are called and the return value has a concrete bytestring type with a defined length, we create a new copy of the function type and overwrite the return type of the function type during annotation invisit_Call
. This lets different calls of the same interface function have different lengths for the same bytestring type.How to verify it
Commit message
Description for the changelog
Remove side effects in compare_type for bytestrings
Cute Animal Picture