You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The compilation of the example above will throw vyper.exceptions.InvalidType: Value and target type are both 'Bytes[11]' instead of vyper.exceptions.TypeMismatch: Can't convert Bytes[10] to Bytes[11]
The first condition in the _cast_bytestring function can't be reached
def_cast_bytestring(expr, arg, out_typ):
# ban converting Bytes[20] to Bytes[21]ifisinstance(arg.typ, out_typ.__class__) andarg.typ.maxlen<=out_typ.maxlen:
_FAIL(arg.typ, out_typ, expr)
# ^- should raise TypeMismatch(f"Can't convert {ityp} to {otyp}", source_expr)
as a note, the root of this issue is that _BytestringT.compare_type is a mutating function. there have been a couple attempts to fix this (most recently, #3379 and #3765) but they are somewhat deep changes and also affect language semantics, so i deferred the work to 0.4.1 or later
Version Information
vyper --version
): 0.4.0rc2+commit.6f09e296Issue description and/or POC
The compilation of the example above will throw
vyper.exceptions.InvalidType: Value and target type are both 'Bytes[11]'
instead ofvyper.exceptions.TypeMismatch: Can't convert Bytes[10] to Bytes[11]
The first condition in the
_cast_bytestring
function can't be reachedDue to the check in the
Convert::infer_arg_types
:Which is triggered by the
_BytestringT
comparison conditions.How can it be fixed?
The text was updated successfully, but these errors were encountered: