MikePopoloski / slang

SystemVerilog compiler and language services
MIT License
558 stars 122 forks source link

"Compilation" AST doesn't have module declaration attributes #887

Closed povik closed 4 months ago

povik commented 4 months ago

Describe the bug The AST one gets from compilation->getRoot() on a built Compilation doesn't seem to provide for a way to get to the attributes that were placed on module declarations.

To Reproduce Using e.g. slang-netlist --ast-json to get the compiled AST dump from

(* see_you_on_the_other_side *)
module top;
endmodule

I see

{
  "name": "$root",
  "kind": "Root",
  "addr": 105553131594176,
  "members": [
    {
      "name": "",
      "kind": "CompilationUnit",
      "addr": 5310197144
    },
    {
      "name": "top",
      "kind": "Instance",
      "addr": 5310197712,
      "body": {
        "name": "top",
        "kind": "InstanceBody",
        "addr": 5310197536,
        "definition": "top"
      },
      "connections": [
      ]
    }
  ]
}

which doesn't mention the attribute. When I put an attribute elsewhere to attach on something other than a module, I see it in the AST dump, which suggests to me attributes are lost for modules but shouldn't be.

MikePopoloski commented 4 months ago

Fixed in 7b7419d03937e9edca837c10db4cfa60f460041b