pub fn unkeyed_stateful_loop<'a>(
def: &ComponentDef<'a>,
all: &[ComponentDef<'a>],
) -> Option<(Symbol, Span)>Expand description
A {for each …:} with NO keyed by whose body reaches a component that owns State:.
★ SILENT STATE CORRUPTION, IN THE MOST ORDINARY SHAPE A PAGE HAS. Without a key an instance is
identified by its POSITION in the list, so the moment the list is reordered or an item is
removed every survivor inherits its neighbour’s state. Measured on a list of three counters
with the second bumped twice and the third once: dropping the FIRST item left the page reading
b:0 c:2 — b took a’s count and c took b’s — while the keyed spelling of the same page
correctly read b:2 c:1. Nothing was reported on either tier.
The framework cannot tell an append-only list (where positional identity is harmless) from one that reorders, so it refuses and names the clause that settles it. That is the same judgement this file makes everywhere else: refused LOUDLY beats rendered wrongly, and a page whose rows quietly swap their contents is as wrong as a page gets.
TRANSITIVE, because the damage is not limited to the component named in the loop: a stateless
<Panel> placed unkeyed still carries a stateful <Tile> inside it, and the <Tile> is the
one that loses its identity. It answers the same question placed_components answers, one
reachability step further out.