While using analyze in periscopic 4.0.3, the ExportNamedDeclaration path for re-exports creates a child scope and returns early. That early return skips the shared unwind step that restores current_scope to its parent. Result: declarations that come after a re-export at module top level are recorded on the export-created child scope instead of the root scope. Minimal reproduction Using acorn + periscopic: Expected Declarations after the re-export should belong to module root scope (or at least be discoverable from rootScope.find_owner). Actual Declarations after the re-export are attached to the export-created child scope, and rootScope.find_owner for those names returns null. Why this seems to happen In the ExportNamedDeclaration with source branch, current_scope is advanced to a new Scope and the branch returns before the shared unwind logic runs (the context.next + parent restore block). That leaves current_scope on the child for subsequent traversal. Impact Consumers that rely on exact ownership scope identity (not just upward lookup from the current active child) can misclassify bindings declared after re-exports. Potential fix Keep the no-descend behavior for re-export specifiers, but restore current_scope before returning in that branch (or refactor so that branch still executes the shared unwind step).
Repository: Rich-Harris/periscopic. Description: Utility for analyzing scopes belonging to an ESTree-compliant AST Stars: 108, Forks: 10. Primary language: JavaScript. License: MIT. Open PRs: 1, open issues: 4. Last activity: 2mo ago. Top contributors: Rich-Harris, mrkishi, tanhauhau, ChristianMurphy, benmccann, remcohaszing, milton-alvarenga, dependabot[bot], theoludwig, github-actions[bot].