vyper
vyper copied to clipboard
Immutables Allowed to Be Used as Default Arguments
Version Information
- vyper Version (output of
vyper --version
): commit4b4e188ba83d28b5dd6ff66479e7448e5b925030
Issue description
According to the documentation, the default arguments of a function must be literals or environment variables, however, immutables are allowed to be used as default arguments.
The following contract compiles:
x:immutable(uint256)
@deploy
def __init__():
x = 1
@external
def foo(val:uint256 = x):
pass
credits: @trocher
this seems kinda useful actually, suggest updating docs?
i'm not sure yet if this is a compiler bug or docs issue, but i'm leaning towards docs issue.
note that this behavior was introduced in https://github.com/vyperlang/vyper/pull/3669, and that this behavior is blocked for pure functions as of https://github.com/vyperlang/vyper/pull/3895 (pure cannot read from runtime code, but view can)