Closed Jampi0n closed 3 years ago
As we discussed in DMs, I will merge this even if the implementation might not be ideal, since it makes the lua backend finally usable and new generics/type classes still seem a bit far in the future. Thanks a lot for all the work you invested into this 👍
This is an attempt to fix the lua bugs described in #994 and #995 (outside of the null string issue). I marked it WIP, because it contains parts that can be improved, needs some clean up and better unit tests. My understanding of the code base is limited, so I'm sure there is lots of stuff that should be done differently.
I will summarize the changes and how it works:
typeFromIndex(...)
->typeFromIndex(intEnsure(...))
andtypeToIndex(...) -> intEnsure(typeToIndex(...))
If for exampleHashMap.get
now returns nil (the indexToObject function will return nil for non existing keys), the intEnsure function that is wrapped aroundHashMap.get
will convert nil to 0. While these functions are added to the intermediate program in lua, the program is still semantically the same as without these function, because they are just identity functions for the intermediate language.This could serve as temporary fix until the new generics are implemented. If this is considered useful I can do some improvements, but I didn't want to spend more time on something that may not be of use.