In the previous step, you guys helped me [make the declareEnum() macro](https://forum.nim-lang.org/t/11331) that generates an enum type. Now, I need to generate a proc that uses the enum type for a parameter. My first attempt employs a template: template declareFieldEnum*( peripheralName: untyped, registerName: untyped, fieldName: untyped, bitOffset: static int, bitWidth: static int, values: untyped ) {.inject.} = declareEnum(`peripheralName _ registerName _ fieldName Val`): values proc `fieldName`*( regVal: `peripheralName _ registerName Val`, fieldVal: `peripheralName _ registerName _ fieldName Val` ): `peripheralName _ registerName Val` {.inline.} = discard # the impl isn't important to this example Run
This gives me the error: `Error: Expected a node of kind nnkAsgn, got nnkStmtList` which suggests a mangled depth of nesting of the `untyped` argument I passed. Is a template the right tool for this? I'm in the deep end and could use another hand. If I can get this going, I have smooth water after this. The problem in isolation [is here (playground)](https://play.nim-lang.org/#pasty=uYjlDjCnrFHZ).