Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing string interpolators, add -Xlint:missing-interpolator (backport #4471) #4473

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ lazy val core = (project in file("core"))
"-language:reflectiveCalls",
"-unchecked",
"-Xcheckinit",
"-Xlint:infer-any"
// , "-Xlint:missing-interpolator"
"-Xlint:infer-any",
"-Xlint:missing-interpolator"
)
)
.dependsOn(macros)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/chisel3/connectable/Connection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private[chisel3] object Connection {
case List(a, b) =>
BiConnect.markAnalogConnected(sourceInfo, a, b, currentModule)
BiConnect.markAnalogConnected(sourceInfo, b, a, currentModule)
case _ => throw new InternalErrorException("Match error: as.toList=${as.toList}")
case _ => throw new InternalErrorException(s"Match error: as.toList=${as.toList}")
}
} catch { // convert Exceptions to Builder.error's so compilation can continue
case attach.AttachException(message) => Builder.error(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ object Hierarchy {
def toTarget: IsModule = i match {
case d: Definition[T] => new Definition.DefinitionBaseModuleExtensions(d).toTarget
case i: Instance[T] => new Instance.InstanceBaseModuleExtensions(i).toTarget
case _ => throw new InternalErrorException("Match error: toTarget i=$i")
case _ => throw new InternalErrorException(s"Match error: toTarget i=$i")
}

/** Returns the toAbsoluteTarget of this hierarchy
Expand All @@ -114,7 +114,7 @@ object Hierarchy {
def toAbsoluteTarget: IsModule = i match {
case d: Definition[T] => new Definition.DefinitionBaseModuleExtensions(d).toAbsoluteTarget
case i: Instance[T] => new Instance.InstanceBaseModuleExtensions(i).toAbsoluteTarget
case _ => throw new InternalErrorException("Match error: toAbsoluteTarget i=$i")
case _ => throw new InternalErrorException(s"Match error: toAbsoluteTarget i=$i")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ final case class Instance[+A] private[chisel3] (private[chisel3] val underlying:
case Proto(value: IsInstantiable) => None
case Clone(i: BaseModule) => Some(i)
case Clone(i: InstantiableClone[_]) => i.getInnerContext
case _ => throw new InternalErrorException("Match error: underlying=$underlying")
case _ => throw new InternalErrorException(s"Match error: underlying=$underlying")
}

/** @return the context this instance. Note that for non-module clones, getInnerDataContext will be the same as getClonedParent */
private[chisel3] def getClonedParent: Option[BaseModule] = underlying match {
case Proto(value: BaseModule) => value._parent
case Clone(i: BaseModule) => i._parent
case Clone(i: InstantiableClone[_]) => i.getInnerContext
case _ => throw new InternalErrorException("Match error: underlying=$underlying")
case _ => throw new InternalErrorException(s"Match error: underlying=$underlying")
}

/** Used by Chisel's internal macros. DO NOT USE in your normal Chisel code!!!
Expand Down Expand Up @@ -84,7 +84,7 @@ object Instance extends SourceInfoDoc {
def toTarget: IsModule = i.underlying match {
case Proto(x: BaseModule) => x.getTarget
case Clone(x: IsClone[_] with BaseModule) => x.getTarget
case _ => throw new InternalErrorException("Match error: i.underlying=${i.underlying}")
case _ => throw new InternalErrorException(s"Match error: i.underlying=${i.underlying}")
}

/** If this is an instance of a Module, returns the toAbsoluteTarget of this instance
Expand All @@ -93,7 +93,7 @@ object Instance extends SourceInfoDoc {
def toAbsoluteTarget: IsModule = i.underlying match {
case Proto(x) => x.toAbsoluteTarget
case Clone(x: IsClone[_] with BaseModule) => x.toAbsoluteTarget
case _ => throw new InternalErrorException("Match error: i.underlying=${i.underlying}")
case _ => throw new InternalErrorException(s"Match error: i.underlying=${i.underlying}")
}

def suggestName(name: String): Unit = i.underlying match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object Lookupable {
newChild.bind(internal.CrossModuleBinding)
newChild.setAllParents(Some(m))
newChild
case _ => throw new InternalErrorException("Match error: newParent=$newParent")
case _ => throw new InternalErrorException(s"Match error: newParent=$newParent")
}
}
}
Expand Down Expand Up @@ -204,7 +204,7 @@ object Lookupable {
val wrMap = mapping.flatMap { case (from, _, wr) => Option.when(wr.isReadOnly)(from -> wr) }.toMap
AggregateViewBinding(newMap, Option.when(wrMap.nonEmpty)(wrMap))
}
case _ => throw new InternalErrorException("Match error: data.topBinding=${data.topBinding}")
case _ => throw new InternalErrorException(s"Match error: data.topBinding=${data.topBinding}")
}

// TODO Unify the following with `.viewAs`
Expand All @@ -218,7 +218,7 @@ object Lookupable {
Builder.unnamedViews += agg
case _ => ()
}
case _ => throw new InternalErrorException("Match error: newBinding=$newBinding")
case _ => throw new InternalErrorException(s"Match error: newBinding=$newBinding")
}

result.bind(newBinding)
Expand Down Expand Up @@ -278,7 +278,7 @@ object Lookupable {
val newChild = Module.do_pseudo_apply(new InstanceClone(m.getProto, () => m.instanceName))
newChild._parent = i._parent
Clone(newChild)
case _ => throw new InternalErrorException("Match error: rec(m)=${rec(m)}")
case _ => throw new InternalErrorException(s"Match error: rec(m)=${rec(m)}")
}
case Clone(m: InstanceClone[_]) =>
rec(m) match {
Expand All @@ -287,9 +287,9 @@ object Lookupable {
val newChild = Module.do_pseudo_apply(new InstanceClone(m.getProto, () => m.instanceName))
newChild._parent = i._parent
Clone(newChild)
case _ => throw new InternalErrorException("Match error: rec(m)=${rec(m)}")
case _ => throw new InternalErrorException(s"Match error: rec(m)=${rec(m)}")
}
case _ => throw new InternalErrorException("Match error: module=$module")
case _ => throw new InternalErrorException(s"Match error: module=$module")
}
}

Expand Down Expand Up @@ -396,7 +396,7 @@ object Lookupable {
newChild.setRef(mem.getRef, true)
newChild
case _ =>
throw new InternalErrorException("Match error: newParent=$newParent")
throw new InternalErrorException(s"Match error: newParent=$newParent")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/chisel3/aop/Select.scala
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ object Select {
case Slot(imm, name) => Seq(imm.id.asInstanceOf[Record].elements(name))
case Index(imm, _) => getEffected(imm)
case LitIndex(imm, _) => getEffected(imm)
case _ => throw new InternalErrorException("Match error: a=$a")
case _ => throw new InternalErrorException(s"Match error: a=$a")
}

// Given an arg, return the corresponding id. Don't use on a loc of a connect.
Expand Down Expand Up @@ -506,7 +506,7 @@ object Select {
case e: ChiselException =>
i.getOptionRef.get match {
case l: LitArg => l.num.intValue.toString
case _ => throw new InternalErrorException("Match error: i.getOptionRef.get=${i.getOptionRef.get}")
case _ => throw new InternalErrorException(s"Match error: i.getOptionRef.get=${i.getOptionRef.get}")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ object QMCMinimizer extends Minimizer {
(maxt ++ dc, false)
case x if !x.mask.testBit(i) => // default to ?
(mint, true)
case _ => throw new InternalErrorException("Match error: table.default=${table.default}")
case _ => throw new InternalErrorException(s"Match error: table.default=${table.default}")
}

implicants.foreach(_.isPrime = true)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/circt/stage/phases/CIRCT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class CIRCT extends Phase {
)
})

logger.info(s"""Running CIRCT: '${cmd.mkString(" ")}""" + input.fold(_ => " < $$input'", _ => "'"))
logger.info(s"""Running CIRCT: '${cmd.mkString(" ")}""" + input.fold(_ => " < $$" + "input'", _ => "'"))
val stdoutStream, stderrStream = new java.io.ByteArrayOutputStream
val stdoutWriter = new java.io.PrintWriter(stdoutStream)
val stderrWriter = new java.io.PrintWriter(stderrStream)
Expand Down