For 3.x functions this is impossible as they do not have type
information. (You would have to call each function with each data type
and see if it fails. Or, you would have to parse the ruby code and then
via static analysis of the ruby code try to determine if a data type is
acceptable or not) = impossible.
For 4.x this is doable. You would first need to load all functions,
then look them up. For the 4.x functions it is possible to get the
signatures defined by the dispatchers, and you can thus calculate the
acceptable data type(s). You can then use the TypeCalculator to compute
the type of the argument (-100 in your example), and then check if the
acceptable data type is assignable from the inferred data type (in the
example an Integer[-100, -100]). When inferring the value you should use
TypeCalculator.infer_set to get the richest possible inference.
With this approach you may get false positives as functions may have a
wider type than what is actually allowed (checked at runtime), or where
there are additional constraints posed by invariant combinations of
parameters. That can probably be ignored for this use case, you would
simply see some methods that may not be applicable.
For 3.x functions, if you were to include them in the list, you would
have to include all of them as you cannot determine if they will work or
not. That in turn is a problem since if you have stdlib included you
would get all of those functions in every list, which would make the
feature less valuable (lots of false entries).
Best,
- henrik