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
vyper Version (output of vyper --version OR linkable commit hash vyperlang/vyper@): b43ffac
Issue Description
Several Vyper constructs require or can be optimized if constant values
are provided. To achieve this, AST nodes can be folded to constants by
the compiler, however, the following locations do not support folding:
length in slice(x, start, length) when x is msg.data or address.code:
isinstance(parent.args[2], vy_ast.Int) in _validate_msg_data_attribute()
isinstance(parent.args[2], vy_ast.Int) in _validate_address_code()
length in slice(x, start, length):
if length_literal is not None condition in Slice.fetch_call_return()
index in variable[index] when the variable is an array.
isinstance(node, vy_ast.Int) in _SequenceT.validate_index_type()
index in variable[index] when the variable is a tuple.
not isinstance(node, vy_ast.Int) in TupleT.validate_index_type()
x or y in x ** y:
left, right = _get_lr() in NumericT.validate_numeric_op()
x in convert(x, T)
_convert._to_int(), _convert.to_decimal() and _convert._cast_bytestring() does not check if expr has a
folded value.
topic in raw_log(topic, data) .
not isinstance(node.args[0], vy_ast.List) in RawLog.infer_arg_types()
POC
The following example demonstrates the different issues.
a: constant(uint256) =12@externaldeffoo():
# The following check is inserted by the compiler although it is not necessary# [assert, [iszero, [shr, 128, 12 <12>]]],b: uint128=convert (a, uint128)
Version Information
vyper --version
OR linkable commit hash vyperlang/vyper@): b43ffacIssue Description
Several Vyper constructs require or can be optimized if constant values
are provided. To achieve this, AST nodes can be folded to constants by
the compiler, however, the following locations do not support folding:
length
inslice(x, start, length)
whenx
ismsg.data
oraddress.code
:length
inslice(x, start, length)
:index
invariable[index]
when the variable is an array.index
invariable[index]
when the variable is a tuple.x
ory
inx ** y
:x
inconvert(x, T)
topic
inraw_log(topic, data)
.POC
The following example demonstrates the different issues.
The text was updated successfully, but these errors were encountered: