From 27eb8cfe8aa5b358765fbf62ea7f7bcac17cd88e Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 18 May 2025 11:25:25 -0400 Subject: [PATCH] Fix extraneous WIDTH warning on assoc.exists() --- src/V3Width.cpp | 4 ++-- test_regress/t/t_assoc.v | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 555518daa..2d80c44f1 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -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); diff --git a/test_regress/t/t_assoc.v b/test_regress/t/t_assoc.v index a37acf9f1..24760e758 100644 --- a/test_regress/t/t_assoc.v +++ b/test_regress/t/t_assoc.v @@ -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);