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

Code calling external contract using interface causes compilation error: Interface parameter default value not applied #2374

Closed
ghost opened this issue Jun 28, 2021 · 4 comments
Assignees
Labels
bug Bug that shouldn't change language semantics when fixed.

Comments

@ghost
Copy link

ghost commented Jun 28, 2021

Version Information

  • vyper Version (output of vyper --version): 0.2.12
  • OS: linux,ubuntu 20.*
  • Python Version (output of python --version): 3.8.5
  • Environment (output of pip freeze): attached as popsicle.txt
    popsicle.txt

What's your issue about?

I define an interface with a default value for one of the parameters like:

interface myInterface:
   def function1 (param1: uint256, param2: uint256=10) -> uint256:

This default value is not applied when omitting the parameter with the default value, like param2 in this example.

Please note:
I am unaware whether I can actually pass default values in the interface definition.
This is an assumption I made because I do this in python all the time. I could not figure it out using the vyper documentation.

  • full output of the error you received*
pack_arguments did not return a value 
This is an unhandled internal compiler error. 

Please create an issue on Github to notify the developers. 
https://github.com/vyperlang/vyper/issues/new?template=bug.md 

Compilation of /home/ethbox/Vyper-Main/VyperTest-002/contracts/interfaceError.vy failed.
  • what command you ran
    I use the tintinweb vyper extension in VScode, which calls vyper to compile. It auto compiles when saving the file

  • the code that caused the failure
    in this example I omit the second argument. passing 5,10 as arguments when calling the function will result in successful compilation

# @version >=0.2.12
externalContract: address 

interface myInterface:
    def function1(param1: uint256, param2: uint256=10) -> uint256: nonpayable

@internal
def callExternalContract() : 
    externalContract: address =  ZERO_ADDRESS
    param1:uint256 = 5
    param2:uint256 = 10
    
    result: uint256 = 0

    # use the interface by passing 1 of the 2 arguments, assuming the default value "param2:uint256 = 10" will be passed
    result = myInterface(externalContract).function1(5)

edits: styling and adding a bit of info

@fubuloubu fubuloubu added the bug Bug that shouldn't change language semantics when fixed. label Jun 28, 2021
@charles-cooper charles-cooper added documentation Documentation bug Bug that shouldn't change language semantics when fixed. and removed bug Bug that shouldn't change language semantics when fixed. documentation Documentation labels Oct 20, 2021
@charles-cooper charles-cooper self-assigned this Oct 20, 2021
@charles-cooper
Copy link
Member

Note: in latest vyper (v0.3.0) this throws the following error

  File "/home/charles/.venvs/vyper/lib/python3.8/site-packages/vyper-0.3.0-py3.8.egg/vyper/old_codegen/external_call.py", line 124, in _external_call_helper
    assert len(contract_sig.args) == len(args_lll)
AssertionError

@fubuloubu
Copy link
Member

Note: in latest vyper (v0.3.0) this throws the following error

  File "/home/charles/.venvs/vyper/lib/python3.8/site-packages/vyper-0.3.0-py3.8.egg/vyper/old_codegen/external_call.py", line 124, in _external_call_helper
    assert len(contract_sig.args) == len(args_lll)
AssertionError

Can this raise an actual compiler warning instead? Or does this indicate an issue with the compiler that should be resolved?

@charles-cooper
Copy link
Member

charles-cooper commented Oct 21, 2021

compiler bug with method resolution, needs fix

@charles-cooper
Copy link
Member

This was fixed in #2526

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that shouldn't change language semantics when fixed.
Projects
None yet
Development

No branches or pull requests

2 participants