Skip to content

Commit

Permalink
Merge pull request #1256 from zeenix/issue-1252
Browse files Browse the repository at this point in the history
🐛 zd: Prefix a local variable w/ `__` so it doesn't conflict w/ fields
  • Loading branch information
zeenix authored Feb 13, 2025
2 parents 062a938 + b5c5fb5 commit cf401c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions zvariant_derive/src/dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ pub fn expand_deserialize_derive(input: DeriveInput) -> Result<TokenStream, Erro
#( let mut #fields = ::std::default::Default::default(); )*

// does not check duplicated fields, since those shouldn't exist in stream
while let ::std::option::Option::Some(key) = access.next_key::<&str>()? {
match key {
while let ::std::option::Option::Some(__key) = access.next_key::<&str>()? {
match __key {
#(#entries)*
}
}
Expand Down
13 changes: 13 additions & 0 deletions zvariant_derive/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,16 @@ fn issues_311() {
pub sinr: Option<i32>,
}
}

#[test]
#[ignore]
fn issues_1252() {
// Issue 1252: Naming a field `key` in a dict struct causes a conflict with variables created by
// `DeserializeDict` macro, ending up with a strange error.
#[derive(DeserializeDict, Type)]
#[zvariant(signature = "a{sv}")]
pub struct OwnedProperties {
key: String,
val: OwnedValue,
}
}

0 comments on commit cf401c0

Please sign in to comment.