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

CompilerPanic caused by using String[64] directly as HashMap key #2237

Closed
picked-a-username opened this issue Nov 30, 2020 · 1 comment · Fixed by #2239
Closed

CompilerPanic caused by using String[64] directly as HashMap key #2237

picked-a-username opened this issue Nov 30, 2020 · 1 comment · Fixed by #2239
Labels
bug Bug that shouldn't change language semantics when fixed.

Comments

@picked-a-username
Copy link

picked-a-username commented Nov 30, 2020

Version Information

  • vyper Version (output of vyper --version): 0.2.7
  • OS: OSX 10.15.6 (19G2021)
  • Python Version (output of python --version): 3.6.8

What's your issue about?

Full Error:

Error compiling: test.vy
vyper.exceptions.CompilerPanic: Number of arguments mismatched: add []

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

  • what command you ran? vyper test.vy
  • the code that caused the failure (see this link for help with formatting code)
struct Thing:
    name: String[64]

indexToThing: public(HashMap[uint256, Thing])
NameToStatus: public(HashMap[String[64], bool])

@external
def foo(_index: uint256):
    
    self.NameToStatus[self.indexToThing[_index].name] = True
    self.indexToThing[_index] = empty(Thing)
    

Detailed steps to reproduce the issue

Save the code above as test.vy and run vyper test.vy to reproduce the issue.

What was the result of the issue

The program failed to compile.

What the expected behaviour is

It is expected to compile successfully.

Temporary Fix

I stored self.indexToThing[_index].name in a variable and then used the variable as the key for self.NameToStatus instead of directly using self.indexToThing[_index].name
Working code:

struct Thing:
    name: String[64]

indexToThing: public(HashMap[uint256, Thing])
NameToStatus: public(HashMap[String[64], bool])


@external
def foo(_index: uint256):
    
    name: String[64] = self.indexToItem[_index].name
    self.NameToStatus[name] = True
    self.indexToThing[_index] = empty(Thing)

@iamdefinitelyahuman iamdefinitelyahuman added the bug Bug that shouldn't change language semantics when fixed. label Nov 30, 2020
@iamdefinitelyahuman
Copy link
Contributor

I took a closer look at this, seems you managed to find two bugs at once :)

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

Successfully merging a pull request may close this issue.

2 participants