diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f7770f6..3ec6b615 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] +- Fix `derivedFrom` on field + ## [v0.30.0] - 2023-08-16 - Add `aarch64` target for releases, more readme badges diff --git a/src/generate/register.rs b/src/generate/register.rs index 82be12ec..ba24bba6 100644 --- a/src/generate/register.rs +++ b/src/generate/register.rs @@ -554,12 +554,11 @@ pub fn fields( let inline = quote! { #[inline(always)] }; for &f in fields.iter() { let mut f = f.clone(); - let mut fpath = None; - let dpath = f.derived_from.take(); - if let Some(dpath) = dpath { - fpath = derive_field(&mut f, &dpath, rpath, index)?; + let mut fdpath = None; + if let Some(dpath) = f.derived_from.take() { + fdpath = derive_field(&mut f, &dpath, rpath, index)?; } - let fpath = fpath.unwrap_or_else(|| rpath.new_field(&f.name)); + let fpath = rpath.new_field(&f.name); // TODO(AJM) - do we need to do anything with this range type? let BitRange { offset, width, .. } = f.bit_range; @@ -601,6 +600,8 @@ pub fn fields( let dpath = ev.derived_from.take(); if let Some(dpath) = dpath { epath = Some(derive_enumerated_values(&mut ev, &dpath, &fpath, index)?); + } else if let Some(path) = fdpath.as_ref() { + epath = Some(path.new_enum(ev.name.clone().unwrap())); } // TODO: remove this hack if let Some(epath) = epath.as_ref() {