@@ -98,7 +98,7 @@ impl PeripheralExt for Peripheral {
9898 // For derived peripherals, only process interrupts
9999 if self . derived_from . is_some ( ) {
100100 if let Some ( deletions) = pmod. get_hash ( "_delete" ) . ok ( ) . flatten ( ) {
101- for ispec in deletions. str_vec_iter ( "_interrupts" ) {
101+ for ispec in deletions. str_vec_iter ( "_interrupts" ) ? {
102102 self . delete_interrupt ( ispec)
103103 . with_context ( || format ! ( "Deleting interrupts matched to `{ispec}`" ) ) ?;
104104 }
@@ -146,16 +146,27 @@ impl PeripheralExt for Peripheral {
146146 }
147147 }
148148 Yaml :: Hash ( deletions) => {
149- for rspec in deletions. str_vec_iter ( "_registers" ) {
149+ for rspec in deletions. str_vec_iter ( "_registers" ) ? {
150150 self . delete_register ( rspec)
151151 . with_context ( || format ! ( "Deleting registers matched to `{rspec}`" ) ) ?;
152152 }
153- for ispec in deletions. str_vec_iter ( "_interrupts" ) {
153+ for ispec in deletions. str_vec_iter ( "_interrupts" ) ? {
154154 self . delete_interrupt ( ispec)
155155 . with_context ( || format ! ( "Deleting interrupts matched to `{ispec}`" ) ) ?;
156156 }
157+ for d in deletions. keys ( ) {
158+ if !matches ! ( d, Yaml :: String ( s) if s == "_registers" || s =="_interrupts" ) {
159+ return Err ( anyhow ! (
160+ "`_delete` requires string value or array of strings"
161+ ) ) ;
162+ }
163+ }
164+ }
165+ _ => {
166+ return Err ( anyhow ! (
167+ "`_delete` requires string value or array of strings"
168+ ) )
157169 }
158- _ => { }
159170 }
160171 }
161172
@@ -168,11 +179,11 @@ impl PeripheralExt for Peripheral {
168179 }
169180
170181 // Handle strips
171- for prefix in pmod. str_vec_iter ( "_strip" ) {
182+ for prefix in pmod. str_vec_iter ( "_strip" ) ? {
172183 self . strip_start ( prefix)
173184 . with_context ( || format ! ( "Stripping prefix `{prefix}` from register names" ) ) ?;
174185 }
175- for suffix in pmod. str_vec_iter ( "_strip_end" ) {
186+ for suffix in pmod. str_vec_iter ( "_strip_end" ) ? {
176187 self . strip_end ( suffix)
177188 . with_context ( || format ! ( "Stripping suffix `{suffix}` from register names" ) ) ?;
178189 }
@@ -210,7 +221,7 @@ impl PeripheralExt for Peripheral {
210221 }
211222
212223 // Handle field clearing
213- for rspec in pmod. str_vec_iter ( "_clear_fields" ) {
224+ for rspec in pmod. str_vec_iter ( "_clear_fields" ) ? {
214225 self . clear_fields ( rspec) . with_context ( || {
215226 format ! ( "Clearing contents of fields in registers matched to `{rspec}` " )
216227 } ) ?;
0 commit comments