Skip to content

fix(native): constant extraction scope bug — local const variables extracted as top-level constants #676

@carlos-alm

Description

@carlos-alm

Problem

The native engine has a scope bug where it extracts local const variables inside functions as top-level constant nodes, while the WASM engine correctly limits constant extraction to program-level declarations.

This causes a parity divergence between engines in the build-parity test. Currently the test works around this by filtering kind != 'constant' from the comparison queries.

Root Cause

crates/codegraph-core/src/extractors/javascript.rs — the find_parent_of_types guard needs to be tightened so that only program-level constant declarations are extracted.

Expected Behavior

Both engines should produce identical constant-kind nodes for the same input. Once this is fixed:

  1. Remove the kind != 'constant' exclusion from tests/integration/build-parity.test.ts
  2. The parity test should pass without any kind filters

Related

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