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.
This commit is contained in:
parent
0fca00cc93
commit
1724e7b146
1 changed files with 13 additions and 1 deletions
|
|
@ -131,7 +131,6 @@ pub struct MainPodBuilder {
|
|||
pub operations: Vec<Operation>,
|
||||
pub public_statements: Vec<Statement>,
|
||||
// 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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue