Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RegisterExtensionType >> function call doesn't match any overload #100

Closed
edwingeng opened this issue Jun 29, 2015 · 4 comments
Closed

RegisterExtensionType >> function call doesn't match any overload #100

edwingeng opened this issue Jun 29, 2015 · 4 comments
Labels

Comments

@edwingeng
Copy link

The first lua.DoString in the following code will result in: function call doesn't match any overload, while the second one won't.

public class Foo
{
    public static void Log1(string msg) { }
}

public static class FooExtension
{
    public static void Log2(this Foo self, string msg) { }
}
UserData.RegisterType<Foo>();
UserData.RegisterType<Dictionary<int, int>>();
UserData.RegisterExtensionType(typeof(FooExtension));

var lua = new Script();
lua.Globals["DictionaryIntInt"] = typeof(Dictionary<int, int>);

var script = @"local dict = DictionaryIntInt.__new(); local v; dict.TryGetValue(0, v)";
lua.DoString(script);
lua.DoString(script);

No exception will be thrown if UserData.RegisterExtensionType is removed.

Unity 5.1.1

@xanathar
Copy link
Member

Suuuper odd.

I'll check immediately!

@xanathar xanathar added the bug label Jun 29, 2015
@xanathar
Copy link
Member

Ok bug found - it's in the management of out parameters of value type (e.g. out int).
The extension method thingie is just a red-herring - it exposes the bug but has no real role in this bug . Fix coming very very soon - at this point I'm targetting a thursday release with cumulative fixes.

@edwingeng
Copy link
Author

Thank you for your quick response :)

xanathar added a commit that referenced this issue Jun 30, 2015
…nagement of out params in overloads and time format in os module).
@xanathar
Copy link
Member

I fixed this on the master branch.. I'll do a release asap.

Just a note: out parameters are ignored by moonsharp in the call and passed as return values.. so:

success, value = dict.TryGetValue(key) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants