From 8f037db2cb3618a0ce62a3d565d9c8736bb196f3 Mon Sep 17 00:00:00 2001 From: Aaron Eline Date: Mon, 6 Nov 2023 16:14:57 +0000 Subject: [PATCH] Dont' generate record literals w/ dup keys --- cedar-policy-generators/src/expr.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cedar-policy-generators/src/expr.rs b/cedar-policy-generators/src/expr.rs index e6a7466f7..a0b50f772 100644 --- a/cedar-policy-generators/src/expr.rs +++ b/cedar-policy-generators/src/expr.rs @@ -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), @@ -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