From 99ac8a134b134713913036013ffdec98ec92c73a Mon Sep 17 00:00:00 2001 From: Albert Magyar Date: Mon, 8 Jun 2020 12:14:10 -0700 Subject: Report Builder.error errors as exceptions outside hardware context (#1425) * Immediately throw Builder.error errors outside hardware context * Add example of hidden no-hardware-context error from #1422 Co-authored-by: Schuyler Eldridge --- core/src/main/scala/chisel3/internal/Builder.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'core/src') diff --git a/core/src/main/scala/chisel3/internal/Builder.scala b/core/src/main/scala/chisel3/internal/Builder.scala index 7e521812..bacc9fee 100644 --- a/core/src/main/scala/chisel3/internal/Builder.scala +++ b/core/src/main/scala/chisel3/internal/Builder.scala @@ -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) -- cgit v1.2.3