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

VIP: Disallow use of value as a variable name in a function input #1877

Closed
iamdefinitelyahuman opened this issue Mar 7, 2020 · 3 comments
Closed
Labels
VIP: Approved VIP Approved

Comments

@iamdefinitelyahuman
Copy link
Contributor

Simple Summary

Vyper should not allow value as a function input variable name.

Motivation

Imagine the following contract Foo:

@public
@payable
def foo(bar: uint256 = 7, value: uint256 = 42):
    pass

and another contract interacting with the previous one:

import first_contract as Foo

@public
def call_to_foo(a: address):
    Foo(a).foo(value=31337)

The use of value as a kwarg typically indicates an amount of ether to send, but because of the input argument the intention becomes ambiguous. Is call_to_foo transferring 31337 wei, or sending an integer of 31337?

Specification

Use of value as a variable name in a function input should raise. We can suggest that users change it to _value.

Backwards Compatibility

It's a breaking change for some contracts, but with a well explained error message it's easily dealt with.

Copyright

Copyright and related rights waived via CC0

@fubuloubu fubuloubu added the VIP: Discussion Used to denote VIPs and more complex issues that are waiting discussion in a meeting label Mar 7, 2020
@fubuloubu fubuloubu mentioned this issue Mar 16, 2020
8 tasks
@fubuloubu fubuloubu added VIP: Approved VIP Approved and removed VIP: Discussion Used to denote VIPs and more complex issues that are waiting discussion in a meeting labels Mar 16, 2020
@fubuloubu
Copy link
Member

Meeting notes: treat gas the same as value (since both are used in kwargs in function calls), disallow in function args only

@charles-cooper
Copy link
Member

Meeting notes: treat gas the same as value (since both are used in kwargs in function calls), disallow in function args only

(gas is currently disallowed as a variable name so this would relax the restriction on gas to only disallow it in function args)

@iamdefinitelyahuman
Copy link
Contributor Author

Closed in #2029

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

No branches or pull requests

3 participants