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

Report Builder.error errors as exceptions outside hardware context (bp #1425) #1470

Merged
merged 1 commit into from
Jun 8, 2020
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
8 changes: 7 additions & 1 deletion core/src/main/scala/chisel3/internal/Builder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,13 @@ private[chisel3] object Builder {
}

def errors: ErrorLog = dynamicContext.errors
def error(m: => String): Unit = if (dynamicContextVar.value.isDefined) errors.error(m)
def error(m: => String): Unit = {
if (dynamicContextVar.value.isDefined) {
errors.error(m)
} else {
throwException(m)
}
}
def warning(m: => String): Unit = if (dynamicContextVar.value.isDefined) errors.warning(m)
def deprecated(m: => String, location: Option[String] = None): Unit =
if (dynamicContextVar.value.isDefined) errors.deprecated(m, location)
Expand Down
7 changes: 6 additions & 1 deletion src/test/scala/chiselTests/ImplicitConversionsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@ class ImplicitConversionsSpec extends ChiselFlatSpec {
import chisel3.util._
assertTypeError("Decoupled(UInt(8.W)).target")
}
}

"X.B for X not in [0,1]" should "throw an exception, even outside hardware context" in {
a [ChiselException] should be thrownBy {
65.B
}
}
}