vyperlang / vyper

Pythonic Smart Contract Language for the EVM
https://vyperlang.org
Other
4.84k stars 789 forks source link

compiler panic when using a builtin function as variable type #3772

Open charles-cooper opened 7 months ago

charles-cooper commented 7 months ago

Version Information

What's your issue about?

repro:

x: as_wei_value

on 8ccacb3f47f864ec2ff64d5f7ca65625e9df6b2f, this produces the following error:

Error compiling: tmp/repro.vy
AttributeError: 'VarInfo' object has no attribute '_invalid_locations'

During handling of the above exception, another exception occurred:

vyper.exceptions.CompilerPanic: unhandled exception 'VarInfo' object has no attribute '_invalid_locations'

  contract "tmp/repro.vy:1", line 1:0 
  ---> 1 x: as_wei_value
  -------^
       2

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

How can it be fixed?

the exception is valid, but the compiler should raise a good error message instead of panicking.

solution should be a single line fix: check if the return value is actually a VyperType before returning from _type_from_annotation

charles-cooper commented 7 months ago

slight improvement to the error message as of a8c6ea284e85348d76be91e1ac53d92180fcf7b0

vyper.exceptions.CompilerPanic: Not a type: {typ_}

  contract "tmp/foo.vy:2", line 2:6 
       1 struct A:
  ---> 2     a:as_wei_value
  -------------^
       3 @external

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
romanagureev commented 6 days ago

Got quite similar compiler panic with modules

A.vy

# pragma version 0.4.1

B.vy

# pragma version 0.4.1
import A

event E:
    a: A

Console

>>> vyper B.vy
Error compiling: B.vy
vyper.exceptions.CompilerPanic: Method must be implemented by the inherited class

  contract "B.vy:4", line 4:0 
       3
  ---> 4 event E:
  -------^
       5     a: A

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