And here is a real problem ;-)
proc select(a, b: Node): Node =
result = if oracle(): a else: b
proc construct(a, b: Node): Node =
result = Node(data: "new", le: a, ri: b)
proc harmless(a, b: Node) =
var x = construct(a, b)
x.data = "mutated"
proc harmful(a, b: Node) =
var x = select(a, b)
x.data = "mutated"
Run
How do we know that `harmful` must not compile but that `harmless` should
compile? In my write tracking analysis I propose yet-another effect,
`returnsNew` that would be computed for `construct` but if we don't want to add
more effects, what else could we do? We could reject `harmless` conservatively,
but that seems to be problematic for real-world code out there.