Week8 - Implement Argument Casting & Bug Fixes

Implement Argument Casting & Bug Fixes

Date: July 10, 2023.

Hello! Late for blog of this week but back with a fantastic news that LFortran can now compile entire codebase of SciPy to ASR. This week I implemented `--implicit-argument-casting` performed a sprint towards getting all files to compile to ASR.

Let's start with `--implicit-argument-casting`. This flag is same as `-fallow-argument-mismatch` in gfortran. This flag allows implicitly casting of arguments to the type of the corresponding dummy arguments. Let's understand this with an example. Here you can see that second argument of `idz_realcomp` is `real*8` but we have passed `complex*16`, this code will throw error with gfortran but on using `-fallow-argument-mismatch` it will compile successfully.

To implement this, we created a new flag `--implicit-argument-casting` and registered it, and when flag is active we implicitly cast the arguments where mismatch is found. Simply, the converted code looks like: . More details about this can be found in PR: 1942

With this done, I performed a sprint to get all files compile to ASR. This mainly invovled bug fixes related to handling of common block variables PR: 1961, duplicating symbols in entry functions PR: 1959, PR: 1956 and many more.

Then we worked to setup CI to test ASR generation on every commit. Details about it can be found at PR: 1964.

All in all with 22.5 hours of work this week, we were able to get all files to compile to ASR. This is a huge milestone for LFortran and we are very close to getting a working compiler. I thank Ondřej Čertík for constantly helping me out and guiding me. Without him this would not have been possible. Along with him efforts from Gagandeep Singh, Thirumalai Shaktivel, Smit Lunagaria, and many others helped us achieve this milestone.

For the next week, I will look into which package we can pick to get it compile to LLVM and align output with gfortran quickly and start working on it.