Open
Description
I wrote this code:
from typed_python import TypeFunction, Class, Final, Member, Entrypoint
class Callback(Class):
def execute(self) -> None:
raise NotImplementedError(self)
@TypeFunction
def TypedCallback(T):
class TypedCallback(Callback, Final, __name__=f"TypedCallback({T.__name__})"):
callback = Member(T)
def __init__(self, callback):
self.callback = callback
def execute(self):
self.callback()
return TypedCallback
@Entrypoint
def makeCallback(callback):
return TypedCallback(type(callback))(callback)
x = ListOf(int)()
@Entrypoint
def f():
x.append(10)
c = makeCallback(f)
Depending on whether i have 'Entrypoint' on makeCallback, I get completely different behavior because with the Entrypoint I get a FunctionType that has typed closures, and without it I get one with PyCell (which we can't compile).
We need to tighten up the way we handle lambdas so that we can use them like this with coherent semantics.