diff --git a/Changes b/Changes index 309dce172..dde4f618f 100644 --- a/Changes +++ b/Changes @@ -15,6 +15,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix naming of "id : begin" blocks. +**** Fix class constructor error on assignments to const. + * Verilator 4.040 2020-08-15 diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 3a47a1d56..34cb1d0da 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1793,6 +1793,7 @@ private: if (nodep->lvalue() && nodep->varp()->direction() == VDirection::CONSTREF) { nodep->v3error("Assigning to const ref variable: " << nodep->prettyNameQ()); } else if (nodep->lvalue() && nodep->varp()->isConst() && !m_paramsOnly + && (!m_ftaskp || !m_ftaskp->isConstructor()) && !VN_IS(m_procedurep, Initial)) { // Too loose, but need to allow our generated first assignment // Move this to a property of the AstInitial block diff --git a/test_regress/t/t_class_new.v b/test_regress/t/t_class_new.v index e370e2e49..88b6fc787 100644 --- a/test_regress/t/t_class_new.v +++ b/test_regress/t/t_class_new.v @@ -5,7 +5,7 @@ // SPDX-License-Identifier: CC0-1.0 class ClsNoArg; - int imembera; + const int imembera; // Ok for new() to assign to a const function new(); imembera = 5; endfunction