neolithos / neolua

A Lua implementation for the Dynamic Language Runtime (DLR).
https://neolua.codeplex.com/
Apache License 2.0
466 stars 76 forks source link

Fixes to overload resolution and exceptions #173

Closed powercode closed 1 year ago

powercode commented 1 year ago

Reworking how FindMethod works.

There are for sure some cleanup that could be done, but now all test cases pass.

I've also added new specific tests for FindMethod in LuaEmitTests.cs.

High level changes are to make FindMethod first filter members to only include valid overloads, and then pass them to the next stage where the best match is determined.

This is done by using penalties for different kinds of conversion, where the method with the lowest penalty is selected. The algorithm can surely be improved.

powercode commented 1 year ago
image

:partying_face:

powercode commented 1 year ago

The algorithm for determining the best match is a hack right now.

It would be good to create tests documenting the desired behavior and then implement a more structured version with precise rules for determining "goodness".

neolithos commented 1 year ago

Defining "goodness" would be a desired wish.

Thx, for the hard work. I will check it over the weekend*. And will push a beta version to nuget.

I fixed the style a little.

`* Edit it might be took a little longer.