Fix extraneous WIDTH warning on assoc.exists()

This commit is contained in:
Wilson Snyder 2025-05-18 11:25:25 -04:00
parent b26658fd96
commit 27eb8cfe8a
2 changed files with 4 additions and 2 deletions

View File

@ -3498,7 +3498,7 @@ class WidthVisitor final : public VNVisitor {
AstNodeExpr* const index_exprp = methodCallWildcardIndexExpr(nodep, adtypep);
newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(), "exists",
index_exprp->unlinkFrBack()};
newp->dtypeSetSigned32();
newp->dtypeSetLogicUnsized(32, 1, VSigning::SIGNED);
} else if (nodep->name() == "delete") { // function void delete([input integer index])
methodOkArguments(nodep, 0, 1);
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE);
@ -3590,7 +3590,7 @@ class WidthVisitor final : public VNVisitor {
AstNodeExpr* const index_exprp = methodCallAssocIndexExpr(nodep, adtypep);
newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(), "exists",
index_exprp->unlinkFrBack()};
newp->dtypeSetSigned32();
newp->dtypeSetLogicUnsized(32, 1, VSigning::SIGNED);
} else if (nodep->name() == "delete") { // function void delete([input integer index])
methodOkArguments(nodep, 0, 1);
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE);

View File

@ -37,7 +37,9 @@ module t (/*AUTOARG*/
v = a[4'd3]; `checks(v, "fooed");
v = a[4'd2]; `checks(v, "bared");
i = a.exists(4'd0); `checkh(i, 0);
if (a.exists(4'd0)) $stop; // Check no width warning
i = a.exists(4'd2); `checkh(i, 1);
if (!a.exists(4'd2)) $stop; // Check no width warning
i = a.first(k); `checkh(i, 1); `checks(k, 4'd2);
i = a.next(k); `checkh(i, 1); `checks(k, 4'd3);
i = a.next(k); `checkh(i, 0);