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

imported types cannot be used in call position #3943

Open
charles-cooper opened this issue Apr 13, 2024 · 0 comments
Open

imported types cannot be used in call position #3943

charles-cooper opened this issue Apr 13, 2024 · 0 comments

Comments

@charles-cooper
Copy link
Member

Version Information

  • vyper Version (output of vyper --version): cb94068

What's your issue about?

the following doesn't compile:

# lib1.vy

from ethereum.ercs import IERC20
# main.vy

import lib1

@external
def foo(x: address):
    s: uint256 = staticcall lib1.IERC20(msg.sender).balanceOf(x)

fails with something like the following:

vyper.exceptions.StructureException: interface vyper/builtins/interfaces/IERC20.vyi is not callable

  contract "tmp/main.vy:12", function "foo", line 12:28 
       11 def foo(x: address):
  ---> 12     s: uint256 = staticcall lib1.IERC20(msg.sender).balanceOf(x)
  ------------------------------------^
       13
charles-cooper added a commit that referenced this issue Apr 14, 2024
this commit allows exporting of `module.<interface>`, and also adds
`module.__interface__` which gives the interface type of the module.
in particular, this makes it easier for users to export all functions
from a module, since they do not need to list out every single function
manually.

note that since `module.__interface__` is actually an interface type, it
can theoretically be used in type expressions, e.g.,
```vyper
    x: module.__interface__ = module.__interface__(msg.sender)
```

however, it doesn't work yet as some additional work is required to
properly thread the type into the type analysis system
(see related: GH #3943).

this commit includes the restriction that only `implement`ed interfaces
can be exported, this makes the most sense from a UX / user intuition
perspective.

---------

Co-authored-by: cyberthirst <cyberthirst.eth@gmail.com>
electriclilies pushed a commit to electriclilies/vyper that referenced this issue Apr 27, 2024
this commit allows exporting of `module.<interface>`, and also adds
`module.__interface__` which gives the interface type of the module.
in particular, this makes it easier for users to export all functions
from a module, since they do not need to list out every single function
manually.

note that since `module.__interface__` is actually an interface type, it
can theoretically be used in type expressions, e.g.,
```vyper
    x: module.__interface__ = module.__interface__(msg.sender)
```

however, it doesn't work yet as some additional work is required to
properly thread the type into the type analysis system
(see related: GH vyperlang#3943).

this commit includes the restriction that only `implement`ed interfaces
can be exported, this makes the most sense from a UX / user intuition
perspective.

---------

Co-authored-by: cyberthirst <cyberthirst.eth@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant