tintinweb/vscode-vyper

Interfaces not linted correctly

Closed this issue · 2 comments

I have an interface that looks like such:

# @version ^0.3.3
@view
@external
def read_stuff() -> uint256: 
    pass

And a contract that looks as such:

# @version ^0.3.3
from interfaces.IFace as IFace

@external
@view
def read_contract(some_address: address) -> uint256:
    myContract: IFace = IFace(some_address)
    return myContract.read_stuff()

According to the docs, this is the correct way to import interfaces and running vyper contracts/MyContract.vy I get the expected bycode output.

However, my extension linter says:

vyper.exceptions.FunctionDeclarationException: Missing or unmatched return statements in function 'read_stuff'vyper.exceptions.FunctionDeclarationException: Missing or unmatched return statements in function 'read_stuff'
contract "contracts/interfaces/IFace.vy", line 3:0
2 @external
---> 3 def read_stuff() -> uint256:
-------^
4 pass


Compilation of /DIR/contracts/interfaces/IFace.vy failed. See above.

Which is an incorrect error, my interface is correct.

Hey @PatrickAlphaC,

thanks for taking the time to file an issue. The output you see is directly from the compiler.

I briefly into it but I am not a vyper expert. Either there is a misunderstanding how imports for interface types work or it is just counter-intuitive and I suggest raising this with the vyper team. (a) the def .. pass declaration should not throw if it is the way to export an interface from another source unit, or (b) there is something wrong with importing interface declarations from other source units.

I am sorry but I don't think there is any reasonable thing I can do to fix this for you.

cheers,
tin

example:

main.vy

# @version ^0.3.3
from foobar import FooBar as FooBar  # does not seem to import the interface FooBar declaration

@external
def test(some_address: FooBar):
    some_address.read_stuff()

foobar.vy

# @version ^0.3.3

interface FooBar:
    def read_stuff() -> uint256: view

@view
@external
def read_stuff() -> uint256: 
    pass  # compiler error when compiling this file.

Yeah... interfaces are a bit tricky in vyper. Thanks for taking a look at this. Will see if we can fix the compiler stuff, but yes an "ignore" would be a great work around.