firely-cql-sdk icon indicating copy to clipboard operation
firely-cql-sdk copied to clipboard

Better error handling of unresolved overloads

Open ewoutkramer opened this issue 1 year ago • 6 comments

If the user made an error in such a way that an overloaded methodgroup either has no exact match or an ambiguous match, we can improve our error reporting by typing the erroneous node with a (subtype) of ChoiceType, including all possible types found in the return types of the highest scoring selected overloads.

E.g. if we have a function f<T>(T,T):T, and the CQL text reads f('string', 4), T cannot be determined. In this case we could type the node with all possible types, i.e. give it a type of Choice(int,string), this way, we would correctly deduce the type in a surrounding statement, e.g. f('hello', 4) + 5.

The same is true for a group of overloads of course.

Our current invocationBuilder is almost ready to handle this situation, simply by taking the possible generic parameter assignments and/or return types of the highest scoring alternatives.

ewoutkramer avatar Oct 28 '23 17:10 ewoutkramer