diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fd13b432e7..d147ff2825 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -76,7 +76,10 @@ jobs: $CHISEL_FIRTOOL_PATH/firtool -version >> $GITHUB_STEP_SUMMARY echo \`\`\` >> $GITHUB_STEP_SUMMARY - name: Test - run: sbt ++${{ inputs.scala }} test + run: | + ./mill firrtl[_].test + ./mill svsim[_].test + ./mill chisel[_].test - name: Binary compatibility # TODO either make this also check the plugin or decide that we don't # support binary compatibility for the plugin @@ -155,7 +158,6 @@ jobs: with: distribution: 'adopt' java-version: '11' - cache: 'sbt' - name: Install CIRCT id: install-circt if: ${{ inputs.circt }} @@ -170,7 +172,7 @@ jobs: dir=$(dirname $(which firtool)) echo "CHISEL_FIRTOOL_PATH=$dir" >> "$GITHUB_ENV" - name: Integration Tests - run: sbt integrationTests/test + run: ./mill integrationTests[_].test # Currently just a sanity check that the benchmarking flow works benchmark: @@ -190,7 +192,7 @@ jobs: run: ./mill benchmark.runJmh std: - name: Standard Library Tests + name: Standard Library runs-on: ubuntu-22.04 strategy: matrix: @@ -207,9 +209,8 @@ jobs: with: distribution: 'adopt' java-version: '11' - cache: 'sbt' - - name: Unit Tests - run: sbt ++${{ inputs.scala }} standardLibrary/test + - name: Compile + run: ./mill stdlib[_].compile website: name: Build Mdoc & Website diff --git a/build.sc b/build.sc index d85e547380..670aa73240 100644 --- a/build.sc +++ b/build.sc @@ -317,7 +317,8 @@ object chisel extends Cross[Chisel](v.scalaCrossVersions) trait Chisel extends common.ChiselModule with CrossSbtModule with ScalafmtModule { override def millSourcePath = super.millSourcePath / os.up - override def scalacOptions = v.commonOptions + // Make sure to include super.scalacOptions for Chisel Plugin + override def scalacOptions = T(super.scalacOptions() ++ v.commonOptions) def svsimModule = svsim(crossScalaVersion) diff --git a/core/src/main/scala/chisel3/ModuleImpl.scala b/core/src/main/scala/chisel3/ModuleImpl.scala index 81c4ae20d1..a04766b8c8 100644 --- a/core/src/main/scala/chisel3/ModuleImpl.scala +++ b/core/src/main/scala/chisel3/ModuleImpl.scala @@ -661,7 +661,12 @@ package experimental { def desiredName: String = simpleClassName(this.getClass) /** Legalized name of this module. */ - final lazy val name = + final lazy val name = { + def err(msg: String, cause: Throwable = null) = { + val msg = s"Error: desiredName of ${this.getClass.getName} is null. " + s"Did you evaluate 'name' before all values needed by desiredName were available? $msg." + throwException(msg, cause) + } try { // PseudoModules are not "true modules" and thus should share // their original modules names without uniquification @@ -671,12 +676,11 @@ package experimental { } } catch { case e: NullPointerException => - throwException( - s"Error: desiredName of ${this.getClass.getName} is null. Did you evaluate 'name' before all values needed by desiredName were available?", - e - ) + err("Try adding -Xcheckinit to your scalacOptions to get a more useful stack trace", e) + case UninitializedFieldError(msg) => err(msg) case t: Throwable => throw t } + } /** Returns a FIRRTL ModuleName that references this object * diff --git a/core/src/main/scala/chisel3/internal/Builder.scala b/core/src/main/scala/chisel3/internal/Builder.scala index f40a65ebc1..61f8f49401 100644 --- a/core/src/main/scala/chisel3/internal/Builder.scala +++ b/core/src/main/scala/chisel3/internal/Builder.scala @@ -813,13 +813,23 @@ private[chisel3] object Builder extends LazyLogging { // Helper for reasonable errors when clock or reset value not yet initialized private def getDelayed[A](field: String, dc: Delayed[A]): A = { - val result = dc.value - if (result == null) { - // TODO add SourceInfo and change to Builder.exception + // TODO add SourceInfo and change to Builder.exception. + def err(extra: String) = { throwException( - s"The implicit $field is null which means the code that sets its definition has not yet executed." + s"The implicit $field is null which means the code that sets its definition has not yet executed. $extra." ) } + val result = + try { + dc.value + } catch { + // If user uses -Xcheckinit there will be additional information. + case UninitializedFieldError(msg) => err(msg) + } + // If user is not using -Xcheckinit, suggest that they do. + if (result == null) { + err("Try adding -Xcheckinit to your scalacOptions to get a more useful stack trace") + } result }