fix syntax error at #[derive(Props)]
using const generics
#1607
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reproduce problem
https://github.com/syrflover/derive-props-with-const-generics
To trigger an error, change the version of dioxus to 0.4 in
Cargo.toml
What is problem
dioxus/packages/core-macro/src/props/mod.rs
Lines 554 to 566 in a3e6d0a
dioxus/packages/core-macro/src/props/mod.rs
Lines 645 to 651 in a3e6d0a
When it is
GenericParam::Const
, it doesn't return anything. However, if that item is included in an iterator, a syntax error occurs because it generates commas as many times as the length of the iterator when creating tokens.How to fixed it
https://github.com/syrflover/dioxus/blob/4f8b60834af43fef879c7eb0ff46b74d23a6eabe/packages/core-macro/src/props/mod.rs#L554-L564
Changed to returns
None
, when it isGenericParam::Const
usingfilter_map
.