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

incorrect exception hint when import alias contains a dot #4278

Open
cyberthirst opened this issue Oct 7, 2024 · 1 comment
Open

incorrect exception hint when import alias contains a dot #4278

cyberthirst opened this issue Oct 7, 2024 · 1 comment

Comments

@cyberthirst
Copy link
Collaborator

Version Information

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

What's your issue about?

the hint constructed at

if "." in alias:
msg = "import requires an accompanying `as` statement"
suggested_alias = node.name[node.name.rfind(".") :]
hint = f"try `import {node.name} as {suggested_alias}`"
raise StructureException(msg, node, hint=hint)

incorrectly contains .

# main.vy
import import_test.foo

throws:

vyper.exceptions.StructureException: import requires an accompanying `as` statement

  contract "tests/custom/main.vy:1", line 1:0 
  ---> 1 import import_test.foo
  -------^

  (hint: try `import import_test.foo as .foo`)

How can it be fixed?

  • off by one in the index
@cyberthirst
Copy link
Collaborator Author

depends on: #4229

will push a fix once we merge

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