Skip to content

Commit

Permalink
Fixed RH-80838
Browse files Browse the repository at this point in the history
  • Loading branch information
eirannejad committed Mar 6, 2024
1 parent 877e6d7 commit 90e7ef8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/runtime/MethodBinder.Solver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/testing/methodtest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}


Expand Down
8 changes: 8 additions & 0 deletions tests/test_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 90e7ef8

Please sign in to comment.