vyper
vyper copied to clipboard
initialisation of stateless modules
Not sure whether this is a bug or feature, but the initialisation of stateless modules compiles:
# lib.vy
@deploy
@payable
def __init__():
pass
@internal
@pure
def _uint256_average(x: uint256, y: uint256) -> uint256:
return unsafe_add(x & y, (x ^ y) >> 1)
# main.vy
import lib
initializes: lib
@deploy
def __init__():
lib.__init__()
@external
@pure
def uint256_average(x: uint256, y: uint256) -> uint256:
return lib._uint256_average(x, y)
seems like it should just emit a warning about it not really being neccessary to do
i'd say if we're going to issue a warning, we might as well issue an error. initializing a stateless module seems like an error tbh. (i think in most languages it would be considered a linter issue, but in vyper we have always been a bit more aggressive about promoting "lint-level" issues into compiler errors).
I think disallowing this behaviour makes most sense, i.e. throw a compiler error.