Skip to content

Commit a123493

Browse files
committed
Provide more information on blackbox parse failure
1 parent a034656 commit a123493

File tree

1 file changed

+9
-4
lines changed
  • clash-lib/src/Clash/Netlist/BlackBox

1 file changed

+9
-4
lines changed

clash-lib/src/Clash/Netlist/BlackBox/Util.hs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ renderElem b (Component (Decl n subN (l:ls))) = do
417417
Just (templ0,_,libs,imps,inc,pCtx) -> do
418418
let b' = pCtx { bbResults = [(o,oTy)], bbInputs = bbInputs pCtx ++ is }
419419
layoutOptions = LayoutOptions (AvailablePerLine 120 0.4)
420-
render = N.BBTemplate . parseFail . renderLazy . layoutPretty layoutOptions
420+
render = N.BBTemplate . parseFail b' . renderLazy . layoutPretty layoutOptions
421421

422422
templ1 <-
423423
case templ0 of
@@ -674,10 +674,15 @@ generalGetDomainConf getDomainMap ty = case (snd . stripAttributes . stripVoid)
674674
Nothing -> error $ "Can't find domain " <> show dom <> ". Please report an issue at https://github.com/clash-lang/clash-compiler/issues."
675675
Just conf -> pure conf
676676

677-
parseFail :: Text -> BlackBoxTemplate
678-
parseFail t = case runParse t of
677+
parseFail :: BlackBoxContext -> Text -> BlackBoxTemplate
678+
parseFail b t = case runParse t of
679679
Failure errInfo ->
680-
error (show (_errDoc errInfo))
680+
error $ unlines
681+
[ "error while parsing blackbox: " <> Data.Text.unpack (bbName b)
682+
, "in component " <> Data.Text.unpack (Id.toText $ bbCompName b)
683+
, "error:"
684+
, show (_errDoc errInfo)
685+
]
681686
Success templ -> templ
682687

683688
idToExpr

0 commit comments

Comments
 (0)