Open ritzdorf opened 4 months ago
One more location to add: default values.
Example:
@external
def foo(x: int256 = 2**255-1):
does not compile with:
TypeMismatch('Expected int256 but literal can only be cast as uint256.', vyper.ast.nodes.Int:
One more location to add: default values.
Example:
@external def foo(x: int256 = 2**255-1):
does not compile with:
TypeMismatch('Expected int256 but literal can only be cast as uint256.', vyper.ast.nodes.Int:
this one is expected behavior i think, since 2**255
is out of bounds of the range of int256
, and compile-time safemath should match runtime safemath.
Version Information
vyper --version
OR linkable commit hash vyperlang/vyper@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
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.