topdown: Fix namespacing to use caller bindings
This change fixes an issue in partial eval where variables in negated
expressions were getting plugged with the wrong set of caller
bindings. The caller bindings identify the context in which plugging
is being performed so that variables can be namespaced and conflicts
can be avoided.
For example, given the query `p[x]` and the rule `p[y] { y = input;
not y = 1; ... }` the first expression in the rule body would
eventually be plugged in the context of the calling query whereas the
second expression would be plugged using a special set of bindings
that ensured namespacing was performed. The problem was that the
partial eval negation implementation was incorrectly choosing the
special binding set.
This change updates partial eval to use the bindings from the top of
the evaluator stack in all cases where variables are plugged with
namespacing enabled. This lets us remove the special "sentinel"
bindings that were used to ensure namespacing was performed and
ensures that variables that appear in the original query are not
namespaced (which is the desired behaviour.)
Fixes #1814
Signed-off-by: Torin Sandall <torinsandall@gmail.com> T
Torin Sandall committed
41f335ef71db3a6a080ed514133985055ae751e4
Parent: 8132ced