Skip to content

複数宣言子 (int x, y;) の 2 個目以降の識別子取りこぼしを修正#47

Merged
TwoSquirrels merged 1 commit into
mainfrom
fix/multi-declarator-identifiers
Jul 11, 2026
Merged

複数宣言子 (int x, y;) の 2 個目以降の識別子取りこぼしを修正#47
TwoSquirrels merged 1 commit into
mainfrom
fix/multi-declarator-identifiers

Conversation

@TwoSquirrels

@TwoSquirrels TwoSquirrels commented Jul 11, 2026

Copy link
Copy Markdown
Owner

概要

struct S { int x, y; }; のように 1 宣言に複数のメンバ宣言子を並べた場合、識別子抽出が 2 個目以降を取りこぼすバグ (#41) を修正する。「過剰検出は安全・取りこぼしだけが依存漏れ」という設計 invariant への違反だった。

変更内容

  • collect_definitionschild_by_field_name("declarator")children_by_field_name("declarator", ..) に変更し、全宣言子を舐めるようにした (name フィールドも同一ループのため統一的に複数対応)
  • テスト captures_all_declarators_in_one_declaration を追加 (むき出し int x, y; と初期化子付き int a = 0, b = 0; の両方)

検証

  • 全テスト・clippy 通過
  • Issue 記載の再現例 (前方宣言のみの factory ヘッダー + auto 受け + 落ちる側の y だけ参照) を実際にバンドルし、main では prune されていた type.hpp がバンドルに残り、コンパイル・実行まで通ることを確認

Closes #41

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved identifier detection for declarations containing multiple declarators, such as int x, y;.
    • Ensures all declared identifiers are recognized in class and struct members.

…aration

collect_definitions took only the first `declarator` field, so bare
field_identifiers after the first (`struct S { int x, y; };` の y) were
dropped — wrapped declarators survived via child recursion, bare struct
members did not. Iterate children_by_field_name to cover them all.

Closes #41

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

collect_definitions now enumerates all declaration names and declarators, capturing identifiers beyond the first in multi-declarator statements. A unit test verifies multiple initialized and uninitialized member declarators.

Changes

Identifier collection

Layer / File(s) Summary
Collect and test all declarators
src/library/identifiers.rs
collect_definitions walks all name and declarator children, with a test covering multiple member declarators in one declaration.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The change addresses issue #41 by iterating all declarators and adds a regression test that captures both identifiers.
Out of Scope Changes check ✅ Passed The PR stays focused on identifier collection and its regression test, with no unrelated code changes shown in the summary.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: missing identifiers in multi-declarator declarations.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/multi-declarator-identifiers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@TwoSquirrels TwoSquirrels changed the title fix(identifiers): collect every declarator in a multi-declarator declaration 複数宣言子 (int x, y;) の 2 個目以降の識別子取りこぼしを修正 Jul 11, 2026
@TwoSquirrels
TwoSquirrels merged commit a41f974 into main Jul 11, 2026
10 checks passed
@TwoSquirrels
TwoSquirrels deleted the fix/multi-declarator-identifiers branch July 11, 2026 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

複数宣言子 (int x, y;) の 2 個目以降の識別子を取りこぼす

1 participant