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 · May be fixed by #4090
Open

imported types cannot be used in call position #3943

charles-cooper opened this issue Apr 13, 2024 · 0 comments · May be fixed by #4090
Labels
bug - type 0 compiler halts or panics instead of generating code bug - UX a bug related to UX release - must release blocker
Milestone

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>
@cyberthirst cyberthirst linked a pull request Aug 2, 2024 that will close this issue
@charles-cooper charles-cooper added this to the v0.4.1 milestone Oct 17, 2024
@charles-cooper charles-cooper added release - must release blocker bug - UX a bug related to UX bug - type 0 compiler halts or panics instead of generating code labels Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - type 0 compiler halts or panics instead of generating code bug - UX a bug related to UX release - must release blocker
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant