You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Slice accessors alias the graph's internal storage #532
g.Edges()[0] = otherEdge mutates the graph. Root().Children()[2] = otherUnit re-parents a subtree.
Both leave the construction checksum describing contents that no longer exist.
Subgraph.Edges documents the defect instead of fixing it: "The returned slice aliases the underlying
storage; callers must not mutate it directly."
Fix:slices.Clone on return. One allocation per call, and external mutation becomes impossible rather
than discouraged — the pointers inside stay identical, which is exactly the sharing the rule permits.
Exit: these three return copies; their "must not mutate" comments are deleted because they are no
longer true; a test writes through each returned slice and asserts the graph is unchanged.
Activity