Skip to content

Commit

Permalink
Avoid possible shadowing of existing bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
danielalvsaaker committed Aug 31, 2022
1 parent 5de8f76 commit 7a69a96
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/sycamore-macro/src/view/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ impl Codegen {
.iter()
.map(|node| {
let quoted = self.view_node(node);
quote! { children.push(#quoted); }
quote! { #quoted, }
})
.collect();
quote! {
::sycamore::view::View::new_fragment({
let mut children = ::std::vec::Vec::new();
#append_nodes
children
::std::vec![
#append_nodes
]
})
}
}
Expand Down
18 changes: 18 additions & 0 deletions packages/sycamore-macro/tests/view/component-pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ pub fn ComponentWithChildren<'a, G: Html>(cx: Scope<'a>, prop: PropWithChildren<
prop.children.call(cx)
}

#[component]
pub fn NestedComponentWithChildren<'a, G: Html>(cx: Scope<'a>, prop: PropWithChildren<'a, G>) -> View<G> {
let children = prop.children.call(cx);

view! { cx,
ComponentWithChildren {
(children)
Component {}
}
}
}

#[component]
pub async fn AsyncComponentWithPropDestructuring<'a, G: Html>(
cx: Scope<'a>,
Expand Down Expand Up @@ -61,6 +73,12 @@ fn compile_pass<G: Html>() {
Component {}
}
};

let _: View<G> = view! { cx,
NestedComponentWithChildren {
Component {}
}
};
});
}

Expand Down

0 comments on commit 7a69a96

Please sign in to comment.