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

Type mismatch between Procedure & Function #242

Closed mtshiba closed 1 year ago

mtshiba commented 1 year ago
for! [1, 2, 3], i ->
    print! i
    print! i

The above code will output

Error[#1070]: File test.er, line 12..14, <module>

12 | for! [1, 2, 3], i ->
   :                 ----
13 |     print! i
   : ------------
14 |     print! i
   : ------------
   :            |- expected: (?T(: Type)) => NoneType
   :            `- but found: (i: ?1(<: Ref(Obj))) -> NoneType

However, this is not enough to determine the cause of the error. It should give a hint that an anonymous function should be changed to a procedure (-> should be changed to =>).