[WIP] Lua typecasting #997
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 example
HashMap.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.