-
-
Notifications
You must be signed in to change notification settings - Fork 825
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 the use of self
as an address
#3701
Comments
I'm for this Wonder if |
it would be more like actually i wonder if we should un-ban calling external functions. especially with #2856, there will be a syntactic distinction between |
Don't have a problem with this, I think originally there is just a difference between internal and external calls (especially with dynamic types) and we wanted to avoid too much complexity in internal dispatching at least until the internals were refactored significantly In solidity there is |
yeah i don't think we need the |
I second this. Since the context is similar, I quickly link to my issue here: #3279. We should generally stop doing implicit |
Doesn't matter a ton, but I like it when self is an address. And yes, I'd also like if contracts could be used as addresses! |
hmm, well at least they should be consistent! |
it looks like prior to v0.2.0, this was actually the default behavior. the following (v0.1.17b!) vyper contract demonstrates: contract Factory:
def getExchange(token_addr: address) -> address: constant
factory: Factory
token: Factory
@public
def test():
assert self.factory.getExchange(self.token) == self this compiles in v0.1.17b. by v0.2.0, this contract (after updating the syntax) is rejected. cf. #1375 (comment) |
haven't made a decision yet here but leaning towards allowing (syntactically free) downcasting from interfaces to addresses. this is something we can do as a non-breaking change in the 0.4.x series. |
Simple Summary
in vyper,
self
has typeaddress
. this VIP disallows that behavior and replaces it withself.address
orcontext.address
.Motivation
can flesh out more but basically, it is not immediately clear what the type of
self
is (it deviates from the pattern set for other contract-like things, for interface addresses are accessed using the.address
member).Specification
change the type of
self
to the module type of the executing context. (not sure if this is practical because of ordering of steps in analysis, but it should look more or less like a module type). replace the current uses ofself
withself.address
or maybe a new special variablecontext.address
.Backwards Compatibility
breaking change
Dependencies
If this VIP depends on any other VIPs being implemented, please mention them.
References
Add any references that this VIP might reference (other VIPs/issues, links to blog posts, etc.)
Copyright
Copyright and related rights waived via CC0
The text was updated successfully, but these errors were encountered: