fix(zig,php parsers): attribute generic-container & anonymous-class methods correctly#127
Open
gadievron wants to merge 2 commits into
Open
fix(zig,php parsers): attribute generic-container & anonymous-class methods correctly#127gadievron wants to merge 2 commits into
gadievron wants to merge 2 commits into
Conversation
…ethods correctly
Zig: methods inside the generic-container idiom 'fn List(comptime T: type) type {
return struct {...} }' were emitted as bare top-level functions (class_name None)
and distinct containers' same-named methods collided. Add _returns_type() and
thread the container fn name as struct context so they qualify as List.method.
PHP: methods inside 'new class {}' anonymous classes had class_name None and
collided across distinct anon classes (data loss via overwrite). Add an
anonymous_class branch synthesizing a stable class@anonymous:<line>:<col> identity
(line+col so multiple anon classes on one line stay distinct).
Tests: 5 new across both parsers (qualified-name + collision regressions, incl.
same-line). zig+php suites: 73 passed. Independent + judge verified, no regression.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ession tests Make the cross-PR dependency self-documenting so a human reviewer OR an agent running the suite on the wrong base sees WHY, not a cryptic failure: - zig test: skipif-guard that probes the PREREQUISITE behavior (a named struct's method extracting — provided by the tree-sitter-zig>=1.1.2 grammar-alignment PRs, not by this fix). On a stale-grammar base the tests skip with an explanatory message instead of failing. Non-circular: the probe uses a named struct, the tests cover the distinct generic-container case. - php test: module-docstring note stating the dependency on the reworked _extract_functions_from_tree traversal. This change is NOT landable on raw upstream master; see Depends-on: PR-87/PR-110/322920e in the PR description. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 18, 2026
Collaborator
Author
|
Heads-up for reviewers/agents: two follow-up fix PRs are stacked on this branch (
Both are draft until #127 merges. |
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.
Zig + PHP: attribute generic-container & anonymous-class methods correctly
Fixes the class-key collapse bug family in the Zig and PHP parsers (cross-parser siblings of the Go generic-receiver fix).
staging/parser-fix-stack, NOTmaster(humans and agents)This change is part of the parser-fix stack and must merge into the integration branch
staging/parser-fix-stack, which already contains every prerequisite it needs. It reachesmasterlater, together with the rest of the stack — not on its own.Do NOT retarget this at
master.masteris missing all three prerequisites below — the two parser rewrites AND the grammar pin:On
masterthe fix is inert and its regression tests fail (Zig) / methods aren't extracted (PHP) — see "Why" below. Because the stack carries all three prerequisites, onstaging/parser-fix-stackthis PR is exactly 4 files and fully green (73 tests pass).Why the order matters (verify it yourself)
master's Zig parser matches stale tree-sitter node names (VarDecl,container_decl,FnProto); the installedtree-sitter-zig(>=1.1.2) emitsvariable_declaration/struct_declaration/function_declaration. #110 realigns the parser to the new names. Until then, Zig struct/method extraction is dead, and this fix (written against the new names) cannot work:PHP similarly needs #111's reworked
_extract_functions_from_treetraversal.Self-guard: the Zig regression test
skips with this exact explanation when run on a base that lacks the prerequisite, so an agent/human running the suite on the wrong base sees why instead of a cryptic failure (it does not silently pass — it reports SKIPPED with the reason).Summary
parsers/zig/function_extractor.py): methods inside the generic-container idiomfn List(comptime T: type) type { return struct { fn push() ... }; }were emitted as bare top-level functions (class_name=None) and distinct containers' same-named methods collided. Fix:_returns_type()+ thread the container fn name as struct context →List.push.parsers/php/function_extractor.py): methods insidenew class {}anonymous classes hadclass_name=Noneand collided across distinct anon classes (silent overwrite / data loss). Fix: ananonymous_classbranch synthesizing a stableclass@anonymous:<line>:<col>identity (line+col so multiple anon classes on one line stay distinct).Tests
5 new (qualified-name + collision regressions, incl. same-line anon classes). On the prerequisite base (
staging/parser-fix-stack) the full zig+php suites are green —73 passed. Independent + judge reviewed.Related
Companion Go PR (
fix(go-parser): key generic-type methods on base type) fixes the same bug family for the Go parser. It is independent — Go uses the stdlibgo/ast(stable node types), so it lands onmasteron its own with no dependency in either direction.