Fix wildcard referring types (#4336) (#4342)

This commit is contained in:
Aleksander Kiryk 2023-07-05 19:08:00 +02:00 committed by GitHub
parent 35d6da391b
commit 399319dc1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -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);

View File

@ -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");