topdown/copypropagation: skip comprehensions when checking eqs (#5372)
CP works as follows, it removes a bunch of questions (details omitted),
and then re-adds them if they provide safety for some variable, or if
they introduce refs and values that aren't "contained" in the existing
body.
For that second part, checking containment, the code looked at all refs (all terms),
regardless of whether they're in comprehensions or not.
Now, in the specific case,
p {
{ 1 | input.foo} # <-- present already
_ = input.foo # <-- required?
}
the fact that `input.foo` is in the body already doesn't make the
second expression any less meaningful: if `input.foo` is undefined, the
comprehension would just be empty. For `p`, however, adding the second
line makes a big difference.
Now, we'll skip comprehensions when checking if a previously-removed equation
should be re-introduced.
I've thrown in another small check to rule out some simple cases that have
popped up when changing the previous containment-check.
Fixes #5367.
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com> S
Stephan Renatus committed
232b0c76e4de6202d2920e0059957461aaccbe84
Parent: da2fb4b
Committed by GitHub <noreply@github.com>
on 11/8/2022, 7:55:04 PM