vyperlang / vyper

Pythonic Smart Contract Language for the EVM
https://vyperlang.org
Other
4.85k stars 791 forks source link

init function calling order does not have a linearization check #3779

Open charles-cooper opened 7 months ago

charles-cooper commented 7 months ago

Version Information

What's your issue about?

init functions can be called before their "dependencies", e.g.

import lib1
import lib2

initializes: lib1[lib2 := lib2]
initializes: lib2

@deploy
def __init__():
    lib1.__init__()  # lib2.__init__() has not been called yet!
    lib2.__init__()

How can it be fixed?

add a dependency constraint for calling init functions

charles-cooper commented 5 months ago

we don't need to get fancy about checking branches and so on -- AST order works fine for satisfying the dependency constraint