Skip to content

Incorrect method overload with objects array #287

Description

@DevCorvette

When I run this code:

using NiL.JS.Core;
using NiL.JS.Core.Interop;

var script = @"
console.log('str: ', container.test('str'));
console.log('1: ', container.test(1));
console.log('1.1: ', container.test(1.1));
console.log('[1, 2]: ', container.test([1, 2]));
";

var context = new Context();
context.DefineConstant("container", new FunctionContainer());
context.Eval(script);

class FunctionContainer : CustomType
{
    public string test(string s)
    {
        return $"it is string {s}";
    }

    public string test(long l)
    {
        return $"it is long {l}";
    }

    public string test(double d)
    {
        return $"it is double {d}";
    }

    public string test(long[] array)
    {
       return $"it is long[] {String.Join(", ", array)}";
    }
}

I got wrong result for array:

str: it is string str
1: it is long 1
1.1: it is double 1,1
[1, 2]: it is long 0

Is it bug?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions