Skip to content

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

@iamdefinitelyahuman

Description

@iamdefinitelyahuman

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions