diff --git a/crates/analyzer/src/traversal/expressions.rs b/crates/analyzer/src/traversal/expressions.rs index dc0fae9fba..877333faf0 100644 --- a/crates/analyzer/src/traversal/expressions.rs +++ b/crates/analyzer/src/traversal/expressions.rs @@ -141,12 +141,12 @@ pub fn expr_list( pub fn expr_repeat( context: &mut dyn AnalyzerContext, - value: Node, - len: Node, + value: &Node, + len: &Node, expected_type: Option<&Array>, ) -> Result { let value = assignable_expr(context, &value, None)?; - let len = if let Constant::Int(len) = eval_expr(context, &len) { + let len = if let Constant::Int(len) = eval_expr(context, &len)? { len } else { panic!("shit") @@ -154,7 +154,7 @@ pub fn expr_repeat( let array_typ = Array { size: len.to_usize().unwrap(), - inner: value.typ, + inner: Box::new(value.typ), }; Ok(ExpressionAttributes { diff --git a/crates/mir/src/lower/function.rs b/crates/mir/src/lower/function.rs index ef6e3445d3..0296be6634 100644 --- a/crates/mir/src/lower/function.rs +++ b/crates/mir/src/lower/function.rs @@ -675,6 +675,21 @@ impl<'db, 'a> BodyLowerHelper<'db, 'a> { self.builder.aggregate_construct(ty, args, expr.into()) } + ast::Expr::Repeat { value, len } => { + let array_type = if let Type::Array(array_type) = self.analyzer_body.expressions[&expr.id].typ.clone() { + array_type + } else { + panic!("shit"); + }; + + let args = (0..array_type.size) + .into_iter() + .map(|_| self.lower_expr_to_value(value)) + .collect(); + let ty = self.expr_ty(expr); + self.builder.aggregate_construct(ty, args, expr.into()) + } + ast::Expr::Bool(b) => { let imm = self.builder.make_imm_from_bool(*b, ty); self.builder.bind(imm, expr.into())