MikePopoloski / slang

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

Scoping issue when evaluating unused parameter default #1009

Closed georgerennie closed 1 month ago

georgerennie commented 1 month ago

Describe the bug When instantiating a module where a parameter has a default that depends on definitions from a package with a structured assignment, slang complains that it can't find a symbol only if when the module is instantiated we try to override the parameter value. If I don't use default I don't seem to get this failure so I'm not entirely sure exactly what is happening here, I think it looks like a scoping issue where when resolving my_pkg::CaseA the wrong scope is being used but I may be wrong.

To Reproduce

package my_pkg;

typedef enum logic {
    CaseA
} unit_t;

typedef struct {
    unit_t val;
} struct_t;

endpackage

module param_top #(
    parameter my_pkg::struct_t Param = '{default: my_pkg::CaseA}
);
endmodule

module top;
param_top f(); // elaborates fine
param_top #(.Param('{my_pkg::CaseA})) g(); // reports error: 'my_pkg' is a package, did you mean to use '::' here?
endmodule

Ran with slang file.sv, latest HEAD (71c4be209f98ec1f5b19649a598c4a5c24bb8aab)

MikePopoloski commented 1 month ago

Fixed in cabaf18c00813cd68a26898546803509434bbd6f