Skip to content
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

Immutables Allowed to Be Used as Default Arguments #3932

Open
cyberthirst opened this issue Apr 10, 2024 · 2 comments
Open

Immutables Allowed to Be Used as Default Arguments #3932

cyberthirst opened this issue Apr 10, 2024 · 2 comments

Comments

@cyberthirst
Copy link
Collaborator

Version Information

  • vyper Version (output of vyper --version): commit 4b4e188ba83d28b5dd6ff66479e7448e5b925030

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

@fubuloubu
Copy link
Member

fubuloubu commented Apr 10, 2024

this seems kinda useful actually, suggest updating docs?

@charles-cooper
Copy link
Member

charles-cooper commented Apr 10, 2024

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 #3669, and that this behavior is blocked for pure functions as of #3895 (pure cannot read from runtime code, but view can)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants