Skip to content

follow-up: use if let Some(child) = ... over node.child(i)? in Verilog extractor for-loops #1116

@carlos-alm

Description

@carlos-alm

Deferred from PR #1107 review.

Original reviewer comment: #1107 (comment)

Context: Greptile observed that several handlers in crates/codegraph-core/src/extractors/verilog.rs use node.child(i)? inside a for i in 0..node.child_count() loop. The ? operator returns from the enclosing function on None rather than skipping the iteration. In practice child_count() always yields valid indices so this works correctly today, but if let Some(child) = node.child(i) is more defensively correct and consistent with the handlers below (handle_package_import, handle_include_directive).

Scope: sweep find_class_name, find_class_superclass, find_function_or_task_name and any similar patterns in the file to use if let Some instead. Same sweep should also check the other native extractors for the same anti-pattern.

Why follow-up: orthogonal style cleanup that doesn't affect correctness on the current grammar — kept out of #1107 to keep that PR focused on the Verilog class extraction fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    follow-upDeferred work from PR reviews that needs tracking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions