From 1724e7b146e4af1ef1c9b376703c4df34890538f Mon Sep 17 00:00:00 2001 From: "Eduard S." Date: Mon, 19 Jan 2026 16:50:02 +0100 Subject: [PATCH] feat: in MainPodBuilder track literal contains in dict_contains (#456) The MainPodBuilder automatically adds contains statements for operations that are created from entries. But if the contains statement was already added manually there will be duplicates. We now track manually added contains statements so that we don't generate duplicates when adding statements from entries that use them. --- src/frontend/mod.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs index 1f5046d..b71ef5c 100644 --- a/src/frontend/mod.rs +++ b/src/frontend/mod.rs @@ -131,7 +131,6 @@ pub struct MainPodBuilder { pub operations: Vec, pub public_statements: Vec, // Internal state - // TODO: track contains ops with literals added explicitly as well. dict_contains: Vec<(Value, Value)>, // (root, key) } @@ -177,6 +176,19 @@ impl MainPodBuilder { pub fn insert(&mut self, public: bool, st_op: (Statement, Operation)) -> Result<()> { // TODO: Do error handling instead of panic let (st, op) = st_op; + + // If we're adding a Contains statement with literal arguments (an Entry), track it in + // `dict_contains` to avoid adding it again via `Self::add_entries_contains`. + if let Statement::Contains( + ValueRef::Literal(dict), + ValueRef::Literal(key), + ValueRef::Literal(_), + ) = &st + { + let root_key = (dict.clone(), key.clone()); + self.dict_contains.push(root_key); + } + if public { self.public_statements.push(st.clone()); }