From 399319dc1c5b76913b0492a54c9248db4a1f38b0 Mon Sep 17 00:00:00 2001 From: Aleksander Kiryk Date: Wed, 5 Jul 2023 19:08:00 +0200 Subject: [PATCH] Fix wildcard referring types (#4336) (#4342) --- src/V3Width.cpp | 4 ++++ test_regress/t/t_assoc_wildcard.v | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 368f2ef29..885388f68 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -2121,6 +2121,10 @@ private: v3Global.rootp()->typeTablep()->addTypesp(newp); } } + if (AstWildcardArrayDType* const wildp + = VN_CAST(nodep->dtypeSkipRefp(), WildcardArrayDType)) { + nodep->dtypep(wildp); // Skip RefDType like for other dynamic array types + } if (VN_IS(nodep->dtypep()->skipRefToConstp(), ConstDType)) nodep->isConst(true); // Parameters if implicit untyped inherit from what they are assigned to const AstBasicDType* const bdtypep = VN_CAST(nodep->dtypep(), BasicDType); diff --git a/test_regress/t/t_assoc_wildcard.v b/test_regress/t/t_assoc_wildcard.v index 2d4e5c782..28fa62037 100644 --- a/test_regress/t/t_assoc_wildcard.v +++ b/test_regress/t/t_assoc_wildcard.v @@ -22,10 +22,15 @@ module t (/*AUTOARG*/ cyc <= cyc + 1; begin // Wildcard + typedef string dict_t [*]; string a [*] = '{default: "nope", "BBBBB": "fooing", 23'h434343: "baring"}; + dict_t b = '{default: "nope", "BBBBB": "fooing", 23'h434343: "baring"}; int k; string v; + v = b["CCC"]; `checks(v, "baring"); + v = b["BBBBB"]; `checks(v, "fooing"); + v = a["CCC"]; `checks(v, "baring"); v = a["BBBBB"]; `checks(v, "fooing");