-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FromMeta parsing doesn't error on unrecognized literals in attribute list #192
Comments
I expect this is being caused because the |
This comment was marked as outdated.
This comment was marked as outdated.
Maybe this block of generated code in the macro is the issue, since it ignores metas that are of the literal type: darling/core/src/codegen/variant_data.rs Lines 60 to 68 in dbdcd93
I suspect the fix might be the following, however it is unclear to me what the ramifications if this code path has broader use: for __item in __items {
if let ::syn::NestedMeta::Meta(ref __inner) = *__item {
let __name = ::darling::util::path_to_string(__inner.path());
match __name.as_str() {
#(#arms)*
__other => { #handle_unknown }
}
+ } else {
+ // TODO: Error?
}
} |
@TedDriggs I've opened a fix for this issue in #193. |
Just wanted to mention that I ran into this. I was trying to parse something like this:
|
darling silently ignored literals in NestedMeta, which could indirectly cause confusing error messages if the user provided something that wasn't of the intended format. This update makes that error more explicit, and includes tests to showcase the behavior. Fixes #192
FromMeta doesn't error in all cases that unexpected tokens end up in the attribute list.
It doesn't error in the case that a string literal is in the attribute list. For example:
#[myattribute(myfield = "export", "randomliteral")]
Parsing the attribute list will error if it sees a field that is anticipated, but not for
"randomliteral"
which it will ignore.cc @jonjove
The text was updated successfully, but these errors were encountered: