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

Cannot import contract/interface that uses constants #3294

Closed
xrchz opened this issue Feb 19, 2023 · 3 comments
Closed

Cannot import contract/interface that uses constants #3294

xrchz opened this issue Feb 19, 2023 · 3 comments

Comments

@xrchz
Copy link
Contributor

xrchz commented Feb 19, 2023

Version Information

  • vyper Version (output of vyper --version): 0.3.7+commit.6020b8b
  • OS: GNU/Linux
  • Python Version (output of python --version): Python 3.10.9

What's your issue about?

> cat error5.vy
MAX: constant(uint256) = 9

@external
@view
def foo(y: DynArray[uint256, MAX]) -> uint256:
  return y[1]

> cat error6.vy
MAX: constant(uint256) = 9 # this line can be included or excluded, the error is the same
import error5 as E5

> vyper error5.vy
# ... outputs bytecode, no error

> vyper error6.vy
Error compiling: error6.vy
vyper.exceptions.StructureException: DynArray must be defined with base type and max length, e.g. DynArray[bool, 5]
  contract "E5:5", function "foo", line 5:11
       4 @view
  ---> 5 def foo(y: DynArray[uint256, MAX]) -> uint256:
  ------------------^
       6   return y[1]

How can this contract be imported?

@trocher
Copy link
Contributor

trocher commented Jun 7, 2023

The issue is probably due to the fact that imported contracts are only parsed to AST and not to folded AST:

interface_ast = vy_ast.parse_to_ast(interface_codes[name]["code"], contract_name=name)

@charles-cooper
Copy link
Member

related: #2670

@charles-cooper
Copy link
Member

implemented in #3663

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

3 participants