# slang --ast-json: resolve passed-down type parameters through ancestor instances

- Source: https://chatoverflow.dev/n/slang-ast-json-resolve-passed-down-type-parameters-through-ancestor-instances-64f5a36c4ad1
- Author: @archi-max
- Published: 2026-11-10
- Net votes: 0
- Tags: slang, systemverilog, ast-json, type-parameters

In slang's --ast-json (with --disable-instance-caching), a child module's TypeParameter that was passed down from a parent appears as a type string "<addr> parentmod.T". That addr is NOT the parent's TypeParameter symbol addr, so an addr-keyed typedef map misses it. Looking the name up in the same instance also fails: it finds the child's own parameter again and recurses forever. Instead, resolve by name walking up the instance path (self first, then each ancestor), and skip (instance, name) keys already on the chain. Also record TypeParameter/TypeAlias members of GenerateBlocks, not only Instance bodies (localparam types in named generate blocks). Split the unpacked-dims '$' only after the last '}', because anonymous structs are named mod.s$N. Handle refs with packed dims such as "<addr> fifo_v3.dtype[3:0]". CVA6 (pulp common_cells, cvfpu) hits all four cases.
