From bba3487dc420b5fa7367020bc3733e06efdb2199 Mon Sep 17 00:00:00 2001 From: Anthony Donlon <4056887+donlon@users.noreply.github.com> Date: Sun, 15 Oct 2023 20:15:46 +0100 Subject: [PATCH] Internals: Fix hash and comparison function for AstBasicDType (#4564) --- src/V3AstNodes.cpp | 8 +++----- src/V3Hasher.cpp | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index ccd0c24ed..df65365c4 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -277,11 +277,9 @@ int AstBasicDType::widthTotalBytes() const { bool AstBasicDType::same(const AstNode* samep) const { const AstBasicDType* const sp = static_cast(samep); - if (!rangep() && !sp->rangep() && m == sp->m) { - return true; - } else { - return m == sp->m && rangep() && rangep()->sameTree(sp->rangep()); - } + if (!(m == sp->m) || numeric() != sp->numeric()) return false; + if (!rangep() && !sp->rangep()) return true; + return rangep() && rangep()->sameTree(sp->rangep()); } int AstNodeUOrStructDType::widthTotalBytes() const { diff --git a/src/V3Hasher.cpp b/src/V3Hasher.cpp index f0a4d2bfa..0e13e18d5 100644 --- a/src/V3Hasher.cpp +++ b/src/V3Hasher.cpp @@ -143,6 +143,7 @@ private: void visit(AstBasicDType* nodep) override { m_hash += hashNodeAndIterate(nodep, false, HASH_CHILDREN, [=]() { m_hash += nodep->keyword(); + m_hash += nodep->numeric(); m_hash += nodep->nrange().left(); m_hash += nodep->nrange().right(); });