erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.69k stars 55 forks source link

More readable error message for function definition #258

Open mtshiba opened 1 year ago

mtshiba commented 1 year ago
add, x: Int, y: Int = x + y

print! add 1, 2

will get

Error[#0361]: File test.er, line 1, <module>::%v0

1 | add, x: Int, y: Int = x + y
  :                       -

x is not defined

Error[#0611]: File test.er, line 1, <module>::add

1 | add, x: Int, y: Int = x + y
  : ---
  :   `- This may be a bug of Erg compiler, please report to https://github.com/erg-lang/erg

Type Failure is not defined

Error[#0611]: File test.er, line 1, <module>::x

1 | add, x: Int, y: Int = x + y
  :      ---
  :        `- This may be a bug of Erg compiler, please report to https://github.com/erg-lang/erg

Type Failure is not defined

Error[#0611]: File test.er, line 1, <module>::y

1 | add, x: Int, y: Int = x + y
  :              ---
  :                `- This may be a bug of Erg compiler, please report to https://github.com/erg-lang/erg

Type Failure is not defined

Error[#1051]: File test.er, line 3, <module>

3 | print! add(1, 2)
  :        ---
  :          |- expected: Callable
  :          `- but found: Failure

the type of ::add(: Failure) is mismatched

This is an error caused by the extra , after add.