This project is read-only.

ParseException when calling method that has the same return type and argument type

Oct 23, 2013 at 2:55 PM
Edited Oct 23, 2013 at 5:26 PM

I try to start using this great library, but I have run into some problems. When I want to use method that has the one of arguments with the same type as return type I get ParseException. Please consider following example:

LINQ query containing following Where clause (I know it doesn't make sense but I just want to call Min method on Math static class):

.Where("Math.Min(1,2) == 1")

When I run code with this query I get exception:
No applicable method 'Min' exists in type 'Math'
I have found out that I can fix this issue by removing following Where clause:
.Where(p => p.ParameterType != ((MethodInfo)m).ReturnType)
from FindBestMethod method in Dynamic.cs file:
MethodData[] applicable = methods.
    Select(m => new MethodData
        MethodBase = m,
        Parameters = m.GetParameters()
            __.Where(p => p.ParameterType != ((MethodInfo)m).ReturnType)__
    Where(m => IsApplicable(m, args)).
I couldn't really find the reason why methods with the same return type and parameter type shouldn't be returned as valid methods. Maybe there is hidden reason behind that ?

I would appreciate any feedback on this issue.

Nov 11, 2013 at 1:36 PM
I will take a look at this as time permits. I'm not sure if that was code I added or something that was already there. If the latter holds true I may not be able to provide a rationale.