erg-lang / erg

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

Procedure as a parameter #301

Closed mtshiba closed 1 year ago

mtshiba commented 1 year ago

Describe the bug?

...

Reproducible code

make_proc(p!: (Int => Int)): (Int => Int) = (y) => p! y

p! = make_proc(x => x)
print! p! 1

Expected result

1

Actual result

Runtime error:

Traceback (most recent call last):
  File "test.er", line -1, in <module>
  File "test.er", line -1, in <lambda>
NameError: name '::x__erg_proc__' is not defined. Did you mean: '::p__erg_proc__'?

Additional context

make_proc(p: (Int => Int)): (Int => Int) = (y) => p y

p! = make_proc(x => x)
print! p! 1

works, but this should be an error because p is type of Procedure and ! suffix must be added.

Erg version

0.6.0-beta.2

Python version

No response

OS

None