Skip to content

Commit

Permalink
Dont' generate record literals w/ dup keys
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronjeline committed Nov 6, 2023
1 parent 565081d commit 8f037db
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cedar-policy-generators/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ impl<'a> ExprGenerator<'a> {
gen!(u,
// record literal
2 => {
let mut r = Vec::new();
let mut r = HashMap::new();
u.arbitrary_loop(
Some(0),
Some(self.settings.max_width as u32),
Expand All @@ -849,13 +849,14 @@ impl<'a> ExprGenerator<'a> {
max_depth - 1,
u,
)?;
r.push((
r.insert(
self.constant_pool.arbitrary_string_constant(u)?,
attr_val,
));
);
Ok(std::ops::ControlFlow::Continue(()))
},
)?;
println!("Vector before conversion: {:?}", r);
Ok(ast::Expr::record(r).expect("can't have duplicate keys because `r` was already a HashMap"))
},
// if-then-else expression, where both arms are records
Expand Down

0 comments on commit 8f037db

Please sign in to comment.