Plugins and overloads don't interact well
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
While working on our own plugin for self-checking proper types and isinstance() I have tried to use get_function_hook() to emit some additional errors for overloaded functions. However this didn't work for three reasons:
- The hook is called for every item in the overload, not for the overload as a whole.
- The overload logic relies on empty
Messagesas a sign of successful match - The errors emitted during overload selection are discarded afterwards, thus discarding the plugin generated errors
This issue can be fixed in three ways:
- Calling the hook on the overload as a whole after selecting the overload variant and type checking it (this however will be a breaking API change)
- Use newly added error codes to only abandon a variant if the error is due to bad argument type (this is however still bad because
check_call()may have anaccept()call possibly triggering almost arbitrary error including a nested function call with bad argument type). - Use a boolean attribute somewhere that will be set by
check_argument_types()and will be reset after return from everyaccept().
I am leaning towards the last option, since it is most principled IMO.
cc @Michael0x2a
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing get_function_hook() through overload selection, check_call(), check_argument_types(), and accept(). Compare how overload matching uses empty Messages and how plugin errors are discarded. Done means plugin-generated errors survive overload selection without incorrectly rejecting valid overload variants, while keeping the selected behavior consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100