Skip to content

Call-site recording: empty spans under //line, and one walker shared by L1 and L3 #26

Closed

Description

@sinha108

Describe the bug
Two problems in how call sites are recorded:

  1. Call nodes under //line directives get empty byte spans (was Call nodes under //line directives get empty byte spans #21). In a file with a //line directive, a call node's positions come from the directive-adjusted line:col, but its byte offsets index the real file. Slicing module.source then returns an empty string, e.g. span.bytes [433,433].
  2. L1 and L3 each walk call sites separately (was Share one call-site walker between L1 and L3 #20). L1 records call sites in buildCallSites (internal/syntactic_analysis/symbol_table.go). L3 repeats the same walk in recordedCalls (internal/dataflow/bodynodes.go), and closures are walked twice the same way (buildInnerCallables and closureUnits). L3 matches its calls to L1's call keys by position in that walk. A count check catches a change in the number of calls, but not a change in order with the same count.

To Reproduce

  1. Create a Go file containing //line virtual.y:900:1, followed by a function that makes calls.
  2. Run cango -i <dir> -a 1 -o /tmp/out.
  3. Inspect those call nodes' span.bytes: start equals end.

Expected behavior

  • span.bytes covers the call's real text in the file. The line:col can stay directive-adjusted or be real, as long as the docs say which.
  • One shared walker yields call sites and closures in recording order for both L1 and L3, so the two cannot drift apart.

Logs
Observed in the testdata/dataflow/linedir fixture added by PR #16.

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions