What I did this week
I completed an early prototype of generic function support in LPython. Given the following simple generic function and its function calls:
T = TypeVar('T') def f(x: T, y: T) -> T: return x + y f(1,2) f('a','b')
The compiler can correspondingly instantiate two functions each for the integer call f(1,2) and character call f('a','b'). The function body is properly generated for the instantiated functions.
Further, the program can also be compiled into LLVM. This is done simply by ignoring the type parameter declaration T = TypeVar('T') as well as the functions involving type parameters.
For reference, all my progress is still kept as an open pull request. This will be merged once we finalize the overall design of generic functions.
What is coming up next week
1. Making decisions on the design for generic functions.
2. Making other examples and adding support for other statements and expressions for generic functions.
Did I get stuck anywhere
While rebuilding the body of the instantiated functions from the generic function, I met more problems with the ASR (LPython's intermediate representation) verification. One particular issue was that it was impossible to understand the problem simply by looking at the structure of the generated ASR. I solved this issue by looking at the other existing visitor classes that also build function bodies and try to mimic their process.