diff --git a/luisa_compute/src/lang/types/shared.rs b/luisa_compute/src/lang/types/shared.rs index a8c4dbb..978a6a1 100644 --- a/luisa_compute/src/lang/types/shared.rs +++ b/luisa_compute/src/lang/types/shared.rs @@ -9,24 +9,25 @@ pub struct Shared { } impl Shared { pub fn new(length: usize) -> Self { + let shared = with_recorder(|r| { + let shared = new_node( + &r.pools, + Node::new( + CArc::new(Instruction::Shared), + ir::context::register_type(Type::Array(ArrayType { + element: T::type_(), + length, + })), + ), + ) + .into(); + + r.shared.push(shared); + shared + }); Self { marker: PhantomData, - node: with_recorder(|r| { - let shared = new_node( - &r.pools, - Node::new( - CArc::new(Instruction::Shared), - ir::context::register_type(Type::Array(ArrayType { - element: T::type_(), - length, - })), - ), - ) - .into(); - - r.shared.push(shared); - shared.into() - }), + node: shared.into(), } } pub fn len_expr(&self) -> Expr {