Template Function sequant::eval::detail::deepest_visible_form¶
Defined in File cell_table.hpp
Function Documentation¶
-
template<typename Candidates>
inline std::optional<CellId> sequant::eval::detail::deepest_visible_form(CellTable const &table, Candidates const &candidates, CellScope const &query)¶ The “which form of this value is visible here” rule, in one place: among
candidates(cell ids, all of one value), the deepest-scoped cell whoseresidency_scopeenclosesquery— the same visibility contract validator rule 1 enforces. Returns nullopt when no candidate is resident atquery; the caller decides what that means (the table builder falls back to the last form so the validator reports the gap; the runtime throws).Tie-break, single rule: at equal scope depth the earlier candidate wins (the comparison is a strict
>), so the answer is a deterministic function of the order the caller supplies — the builder supplies a value’s forms in emission order, andCellRegistry::cell_ofsupplies Build cells before Assemble cells, which is how it prefers a Build. On a well-formed table the tie cannot arise (rule 5 forbids two Builds of one value at one scope, and a Build and an Assemble of one value never coexist at one scope), so this only keeps hand-built tables deterministic.Used by cell_table_builder.hpp’s read-source selection and by
CellRegistry::cell_of, so the static table and the runtime cannot disagree about which form a scope sees.