pub fn walk_program_interpolated(
source: &str,
program: &[SNode],
visitor: &mut impl FnMut(&SNode),
)Expand description
Walk program INCLUDING the expressions inside ${...} string
interpolation.
walk_program cannot reach them: the lexer stores a hole as unparsed
source text plus a position, so Node::InterpolatedString is a leaf with no
AST children by construction. Any analysis that asks “is this name used?”
and walks with walk_program alone answers NO for a name used only inside
a hole — an unsound answer, not merely an incomplete one.
That is not hypothetical. The whole-program capability solver computed a
helper’s required capabilities that way, concluded random was unused
because its only use was "...${harness.random.uuid_v7()}", and deleted it
from the parameter type and every call site. The repair runs automatically
in the fleet bump workflow, so it rewrote working code into code that does
not compile (value of type nil has no method uuid_v7) and shipped it as a
bump PR (harn-cloud#1469).
source must be the whole file program was parsed from, so re-parsed
holes carry spans in the containing file’s coordinates and stay safe to edit
against. A hole that fails to re-parse is skipped: it cannot be a well-typed
use, and the containing parse already reported it.