From 90e7ef8c5eb6ff2600718dbf7f7830d1b45de1af Mon Sep 17 00:00:00 2001 From: eirannejad Date: Wed, 6 Mar 2024 10:31:18 -0800 Subject: [PATCH] Fixed RH-80838 --- src/runtime/MethodBinder.Solver.cs | 12 +++++++----- src/testing/methodtest.cs | 4 ++++ tests/test_method.py | 8 ++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/runtime/MethodBinder.Solver.cs b/src/runtime/MethodBinder.Solver.cs index cfdfaa337..be684005f 100644 --- a/src/runtime/MethodBinder.Solver.cs +++ b/src/runtime/MethodBinder.Solver.cs @@ -760,11 +760,6 @@ static bool TryBindByValue(int count, continue; } - if (prov.GivenArgs == 0) - { - goto ambiguousError; - } - // NOTE: // if method has the same distance, lets use the one // with the least amount of optional parameters. @@ -804,6 +799,13 @@ static bool TryBindByValue(int count, continue; } + // NOTE: + // if none of the resolutions above worked out, return error + if (prov.GivenArgs == 0) + { + goto ambiguousError; + } + // NOTE: // if method has the same distance, and have the least // optional parameters, and least amount of 'out' params, diff --git a/src/testing/methodtest.cs b/src/testing/methodtest.cs index e3e2e6908..d3daac845 100644 --- a/src/testing/methodtest.cs +++ b/src/testing/methodtest.cs @@ -789,6 +789,10 @@ public static int TryGetComplex(DateTime datetime, out Complex complex, double t complex = default; return 4; } + + public static bool TryGetMultipleOutsOverloaded(out int first) { first = 42; return true; } + + public static bool TryGetMultipleOutsOverloaded(out int first, out double second) { first = 42; second = 42d; return true; } } diff --git a/tests/test_method.py b/tests/test_method.py index b33ba25d7..fb5753101 100644 --- a/tests/test_method.py +++ b/tests/test_method.py @@ -1391,3 +1391,11 @@ def test_method_tryout_multiple_signatures(): result = MethodTest.TryGetComplex(DateTime.Now, outcomplex, 0.1) assert result == 4 assert isinstance(outcomplex.Value, Complex) + + +def test_method_overload_multiple_outs(): + res, first = MethodTest.TryGetMultipleOutsOverloaded() + assert first == 42 + + with pytest.raises(ValueError): + _0, _1, _2 = MethodTest.TryGetMultipleOutsOverloaded()