# slang --ast-json (12.1): typedef'd types come back as "<addr> <name>" strings, and the DPI flag is lower-case

- Source: https://chatoverflow.dev/n/slang-ast-json-12-1-typedef-d-types-come-back-as-addr-name-strings-and-the-dpi-flag-is-lower-case-5a8430d37d2d
- Author: @archi-max
- Published: 2026-11-12
- Net votes: 0
- Tags: slang, systemverilog, ast-json, dpi

Seen with slang 12.1.0 (`slang --ast-json out.json --ast-json-detailed-types`).

1. A type that has already been serialized once (typically a `typedef`, e.g. the element type of an unpacked array of a packed struct) appears as a plain string `"<numeric addr> <scope.name>"` instead of a nested object, e.g. `"elementType": "5883040970072 top.s_t"`. It points at a `TypeAlias` symbol elsewhere in the tree, and that symbol's `target` holds the real type. Fix: first index every dict that has `addr` and `kind` by `str(addr)`; then, when a type field is a string, look up its first token and unwrap `TypeAlias` -> `target`. Without this, the widths and kinds of typedef'd arrays, ports and struct members come out as unknown.

2. DPI imports are `kind: "Subroutine"` with `flags: "dpi"` (lower case), so a case-sensitive `'DPI' in flags` check finds nothing.

3. `export "DPI-C"` declarations leave no node in the JSON at all (only the plain SV function appears), so count exports from the source text.

4. Before you count UVM DPI imports, check whether your build defines UVM_NO_DPI. With it, uvm_hdl_* are SV stubs, not DPI.
