From 6d630cddc73ac46ee7549d8e9291a64a2aba3be0 Mon Sep 17 00:00:00 2001 From: Luke Chu <37006668+lukechu10@users.noreply.github.com> Date: Sun, 3 Nov 2024 18:00:56 +0000 Subject: [PATCH] Fix error and add test --- packages/sycamore-macro/src/inline_props.rs | 5 ++--- .../tests/component/inline-props-pass.rs | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/sycamore-macro/src/inline_props.rs b/packages/sycamore-macro/src/inline_props.rs index 4a327153..3c2c5ab0 100644 --- a/packages/sycamore-macro/src/inline_props.rs +++ b/packages/sycamore-macro/src/inline_props.rs @@ -2,8 +2,7 @@ use proc_macro2::Span; use quote::format_ident; use syn::punctuated::Punctuated; use syn::{ - Field, GenericParam, Generics, Ident, Path, PathArguments, PathSegment, Token, Type, - TypeImplTrait, TypeParam, TypePath, Visibility, + Attribute, Field, GenericParam, Generics, Ident, Path, PathArguments, PathSegment, Token, Type, TypeImplTrait, TypeParam, TypePath, Visibility }; pub fn create_generic_ident(generics: &Generics) -> Ident { @@ -85,7 +84,7 @@ pub fn add_generic(generics: &mut Generics, impl_type: TypeImplTrait) -> Type { }) } -pub fn push_field(fields: &mut Vec, generics: &mut Generics, attrs: Vec, ident: Ident, ty: Type) { +pub fn push_field(fields: &mut Vec, generics: &mut Generics, attrs: Vec, ident: Ident, ty: Type) { let ty = resolve_type(generics, ty); fields.push(Field { diff --git a/packages/sycamore-macro/tests/component/inline-props-pass.rs b/packages/sycamore-macro/tests/component/inline-props-pass.rs index bc31f23f..3c6a99c0 100644 --- a/packages/sycamore-macro/tests/component/inline-props-pass.rs +++ b/packages/sycamore-macro/tests/component/inline-props-pass.rs @@ -84,4 +84,19 @@ fn AdditionalStructAttributes(dummy: String) -> View { } } +#[component(inline_props)] +fn PropsWithAttributes( + #[prop(default)] + dummy: String, +) -> View { + fn call_component() -> View { + view! { + PropsWithAttributes {} + } + } + view! { + (dummy) + } +} + fn main() {}