cython icon indicating copy to clipboard operation
cython copied to clipboard

Improve C++ non-member operator lookup

Open da-woods opened this issue 3 years ago • 1 comments

Supersedes https://github.com/cython/cython/pull/4542 hopefully and fixes https://github.com/cython/cython/issues/4539

This PR is a little less drastic in the changes it makes - it doesn't try to move complete validation into PyrexTypes.best_match (given that for most functions the validation happens in analyse_types).

It modifies best_match slightly so it can take an optional arg0 argument (that only applies to non-member functions). This allows member functions to be compared directly with nonmember functions so that all the alternatives for operators (member functions, non-member functions declared in a global scope, non-member functions declared in a class scope) can be evaluated in one go.

In the case where a single argument exists it evaluates the suitability in the UnopNode.analyse_types by attempting coercion. This basically matches what BinopNode currently does so seems a sensible approach.

da-woods avatar Feb 05 '22 22:02 da-woods

Mentioning the related issue here, so github links them: #4539

maxbachmann avatar Jun 07 '22 10:06 maxbachmann