Repository navigation
fix(python): recognize cdef/cpdef return-type functions in args counting - #2250
Merged
Merged
Conversation
Cython cdef/cpdef declarations with a C return type before the function name (e.g. `cdef char *get_item_pointer(...)`) reported args=0 -- the args regex only matched literal `def`/`lambda`, and previously relied on `def`'s accidental substring match inside `cdef` itself, which breaks the instant a return-type token intervenes. Mirrors func_start's own cdef/cpdef return-type-skipping structure (#1999) for the args rule. Confirmed on language-crucible's cython/MemoryView.pxd/.pyx: 9 sampled real functions (get_item_pointer, copy_data_to_temp, array_cwrapper, memoryview_check, transpose_memslice, _unellipsify, memoryview_copy_contents, _copy_strided_to_strided, slice_assign_scalar) went from args=0 to their correct nonzero counts. Plain def/lambda and the accidental-but-correct bare-cdef case are unaffected. Closes #2238 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2238. GitGalaxy's python
argsrule only matched literaldef/lambda— nocdef/cpdefalternative existed. A barecdef name(...)with no return type happened to get the correct count by accident (the regex's literaldefsubstring matches insidecdef), but the instant a C return-type token intervened (char,void, a Tempita{{...}}placeholder), that accidental adjacency broke and args fell back to 0.Mirrors
func_start's own cdef/cpdef return-type-skipping structure (already correct per #1999) for theargsrule.Evidence
Real functions in
language-crucible/data/python/cython/MemoryView.pxd/.pyx, before → after:get_item_pointercopy_data_to_temparray_cwrappermemoryview_checktranspose_memslice_unellipsifymemoryview_copy_contents_copy_strided_to_stridedslice_assign_scalarPlain
def foo(a, b):,lambda x, y: ..., and the accidental-but-correct bare-cdef name(self, obj)case are all unchanged.Verification
pytest tests/extraction/languages/test_python.py -q— 79 passed (3 new cases + dedicated regression test)audit_check.py --ci— cleancrucible_check.py --mode both— drift confined to python/cython (blessed, matches the fix's intent)tree_sitter_accuracy_audit.py --all --ci— cleantri_comparison_chart.py --all --ci— clean🤖 Generated with Gemini (via
agy), orchestrated and independently verified by Claude Code.