Skip to main content

Module function_facts

Module function_facts 

Source
Expand description

Local, derivable facts about an expression’s ability to modify data.

Expr::contains_mutation answers “does this tree itself write?” as a single yes/no. This module extracts the three facts a call-graph answer needs instead: whether the tree writes directly, which user-defined functions it calls (their stored bodies carry the rest of the answer), and whether it invokes something whose body cannot be inspected at all. The caller combines these facts across function bodies with two polarities:

  • Precise (“provably writes”): only direct_writes, unioned over the reachable call graph. Opaque callables count as clean, because refusing them would refuse working read-only bodies (a pure script, a pure eval).
  • Conservative (“possibly writes”): direct_writes or opaque_effects anywhere reachable. This is the polarity a planner must use before treating an expression as read-only.

Known envelope: a closure value that reaches an invocation site as data is invisible to this walk when the site itself looks harmless — as an argument to a closure-taking builtin (array::map($arr, $fn)), or stored on the receiver under a name that shadows a registered builtin method. This matches the executors’ own access-mode analysis. The runtime write refusal and the transaction’s own write gate remain the backstop for those shapes. Method calls whose name is not a registered builtin can only resolve to such a closure, so they count as opaque here.

Structs§

FunctionFacts
What one expression tree contributes to a mutability answer, before any callee bodies are consulted.