Skip to content

Commit

Permalink
Fix parameter default value visitor
Browse files Browse the repository at this point in the history
  • Loading branch information
MikePopoloski committed May 26, 2024
1 parent cad94bc commit cabaf18
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/ast/symbols/ParameterSymbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ void ParameterSymbolBase::checkDefaultExpression() const {

for (auto& selector : result.selectors) {
if (auto elemSel = std::get_if<0>(&selector))
visitDefault(**elemSel);
(*elemSel)->visit(*this);
}
}

void handle(const AssignmentPatternItemSyntax& syntax) {
// Avoid visiting the key which can name a struct member
// and so should not be looked up.
visitDefault(*syntax.expr);
syntax.expr->visit(*this);
}

const ASTContext& context;
Expand Down
30 changes: 30 additions & 0 deletions tests/unittests/ast/ParameterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,3 +1181,33 @@ endmodule
compilation.addSyntaxTree(tree);
NO_COMPILATION_ERRORS;
}

TEST_CASE("Parameter default checking error regress -- GH #1009") {
auto tree = SyntaxTree::fromText(R"(
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();
endmodule
)");

Compilation compilation;
compilation.addSyntaxTree(tree);
NO_COMPILATION_ERRORS;
}

0 comments on commit cabaf18

Please sign in to comment.