Filterx partial container evaluation#869
Conversation
82e7d48 to
f707716
Compare
f85a922 to
cbecee3
Compare
alltilla
left a comment
There was a problem hiding this comment.
Done one round of review, found no problems. I will do another round.
|
I managed to trigger a jump on uninitialized value with this config: |
|
We have a breaking behavior with this config: On main this produces: With the PR: I don't know how to feel about this. I think the behavior on main is more intuitive and better defined. However implementing something that would offer the old behavior seems unreasonably complex in my head. |
fixed. thanks for finding this. |
I decided to bail out from the optimization step if we have overlapping keys in any way. That basically pushes the evaluation of the dict to runtime, instead of compile time, but I don't think this case is very common, so I don't care if these dicts are not optimized. |
e97b6f6 to
14ea32b
Compare
…line Signed-off-by: Balazs Scheidler <[email protected]>
Signed-off-by: Balazs Scheidler <[email protected]>
Signed-off-by: Balazs Scheidler <[email protected]>
Signed-off-by: Balazs Scheidler <[email protected]>
Signed-off-by: Balazs Scheidler <[email protected]>
…ry() Signed-off-by: Balazs Scheidler <[email protected]>
Signed-off-by: Balazs Scheidler <[email protected]>
…) function Signed-off-by: Balazs Scheidler <[email protected]>
Earlier, both the list/dict evaluation was performed by the same set of functions, which is changed by this patch, as: * lists do not have a "nullv" variant * lists don't have keys Even though we can consider this code duplication, each implementation is somewhat simpler and some of the code can later be refactored to use smaller chunks of reusable code. Signed-off-by: Balazs Scheidler <[email protected]>
… method Signed-off-by: Balazs Scheidler <[email protected]>
Signed-off-by: Balazs Scheidler <[email protected]>
…ction Reflect these assumptions in the container specific code: * dicts always have a key * lists don't have keys * lists don't have nullv style initializers Signed-off-by: Balazs Scheidler <[email protected]>
Previously these were shoveled into the same function with scattered conditionals, split them up and try to create smaller reusable snippets. Signed-off-by: Balazs Scheidler <[email protected]>
…tion time Even if the dict has a non-literal initializer, we can still partially initialize it, so we can simply clone it at runtime and fill in the rest. Signed-off-by: Balazs Scheidler <[email protected]>
…at runtime Signed-off-by: Balazs Scheidler <[email protected]>
We should not set the parent container in this case. Signed-off-by: Balazs Scheidler <[email protected]>
…fails Signed-off-by: Balazs Scheidler <[email protected]>
If we are unable to initialize a dict, the anchors we stored in the elems array is invalid, reset them to the default value. Signed-off-by: Balazs Scheidler <[email protected]>
…ded from early eval
As the order of initialization could depend on whether it was early evaluated
or not, with a config like this:
filterx {
barvalue = "newbarval";
d = {
"foo": "fooval",
"bar": barvalue,
"bar": "barval",
};
$MSG = d;
};
Signed-off-by: Balazs Scheidler <[email protected]>
14ea32b to
66589ea
Compare
|
thank you :) |
This PR allows dict definitions to be partially evaluated even if they have non-literal initializers. A sparse dictionary will
be initialized in this case, literal elements will be completely set, non-literal ones will be stored as nulls, which then will
be completed at execution time.