Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/ast/InstanceCacheKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ InstanceCacheKey::InstanceCacheKey(const InstanceSymbol& symbol, bool& valid,
auto [iface, modport] = conn->getIfaceConn();
while (iface && iface->kind == SymbolKind::InstanceArray) {
auto& arr = iface->as<InstanceArraySymbol>();
if (arr.empty())
if (arr.elements.empty())
iface = nullptr;
else
iface = arr.elements[0];
Expand Down
34 changes: 34 additions & 0 deletions tests/unittests/ast/InterfaceTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,3 +940,37 @@ endmodule
REQUIRE(diags.size() == 1);
CHECK(diags[0].code == diag::VirtualInterfaceIfaceMember);
}

TEST_CASE("Arrayed interface port cache regress -- GH #1947") {
// NoAck has no 'ack', so on_no_ack is in error. It is written second because that is
// the instance a shared body would hide.
auto tree = SyntaxTree::fromText(R"(
interface HasAck;
logic req;
logic ack;
endinterface

interface NoAck;
logic req;
endinterface

module Reader (interface a[2]);
initial $display("%b", a[0].ack);
endmodule

module top;
HasAck has_ack [2] ();
NoAck no_ack [2] ();

Reader on_has_ack (.a(has_ack));
Reader on_no_ack (.a(no_ack));
endmodule
)");

Compilation compilation;
compilation.addSyntaxTree(tree);

auto& diags = compilation.getAllDiagnostics();
REQUIRE(diags.size() == 1);
CHECK(diags[0].code == diag::CouldNotResolveHierarchicalPath);
}
Loading