Fix unique_index method on assoc arrays with values differing from the keys (#7616)

Signed-off-by: Pawel Klopotek <[email protected]>
This commit is contained in:
Pawel Klopotek
2026-05-19 09:51:23 -04:00
committed by GitHub
parent 662cd43348
commit efdc8d1cbf
3 changed files with 9 additions and 1 deletions
+1
View File
@@ -218,6 +218,7 @@ Paul Bowen-Huggett
Paul Swirhun
Paul Wright
Pawel Jewstafjew
Pawel Klopotek
Pawel Kojma
Pawel Sagan
Pengcheng Xu
+1 -1
View File
@@ -1090,7 +1090,7 @@ public:
}
VlQueue<T_Key> unique_index() const {
VlQueue<T_Key> out;
std::set<T_Key> saw;
std::set<T_Value> saw;
for (const auto& i : m_map) {
auto it = saw.find(i.second);
if (it == saw.end()) {
+7
View File
@@ -23,6 +23,7 @@ module t;
int qv[$]; // Value returns
int qi[$]; // Index returns
point points_q[int];
point points_qe[int]; // Empty points
point points_qv[$];
int i;
bit b;
@@ -58,6 +59,12 @@ module t;
qi.sort;
`checkp(qi, "'{'h0, 'h1, 'h5}");
qi = points_qe.unique_index();
`checkp(qi, "'{}");
qi = points_q.unique_index();
`checkh(qi.size, 3);
qi = points_q.find_first_index with (item.x == 1);
`checkp(qi, "'{'h0}");
qi = points_q.find_first_index with (item.x == 10);