ApeWorX / ape-vyper

Vyper compiler plugin for the Ape Framework, using VVM
https://www.apeworx.io/
Apache License 2.0
26 stars 9 forks source link

fix: show line numbers on compiler fail [APE-731] #83

Closed antazoey closed 1 year ago

antazoey commented 1 year ago

What I did

when failing to compile a vyper file, show the formatted message. this will include line numbers whenever applicable!

fixes: #71

errors looks like this now:

UndeclaredDefinition:'hello' has not been declared
  contract "contract_undeclared_variable.vy", function "foo1", line 5:4 
       4 def foo1() -> bool:
  ---> 5     hello = world
  -----------^
       6     return True

notice the line nos

How I did it

use formattedMessage instead of message when it is present.

How to verify it

take a contract like this:

@external
def foo1() -> bool:
    hello = world
    return True

try to compile it:

ape compile

you should see an error like this now:

ERROR: (VyperCompileError) und.vy
UndeclaredDefinition:'hello' has not been declared. 
  contract "und.vy:5", function "foo1", line 5:4 
       4 def foo1() -> bool:
  ---> 5     hello = world
  -----------^
       6     return True

before, it was just something like

ERROR: (VyperCompileError) und.vy
UndeclaredDefinition:'hello' has not been declared. 

yay

Checklist

antazoey commented 1 year ago

ya just fixed this because was getting annoyed myself when debugging stuff working on the fallback feature