What I did this week
Continuing on the restriction's work from last week, I implemented more support for restriction check on both generic function definition and generic function call. So let's say we have the following function:
T = TypeVar('T', bound=SupportsZero) def f(x: T) -> T print(x) x = 0 return x f(1) f('a')
For the function definition, the assignment x = 0 would check whether the type of x supports zero assignment (SupportsZero) or not. In this case, it does, so it passes the type check.
For the first function call, because 1 is an integer, it is possible to reassign it with zero. But in the second function call, the character a cannot be reassigned with the number zero. The type check considers this and reject the second function call.
What is coming up next week
1. Access the current restriction design on ASR level
2. Provide more flexible support for generic array
Did I get stuck anywhere
I'm currently a bit confused on how to make a decision for the restriction design on the ASR level. My mentor has provided some high-level design that we want to realize in LPython, but I have not grasped the concrete design yet. I will consult on this matter with my mentor ASAP.