Skip to content

Commit fadedce

Browse files
Fix argument parsing in clashCompileError (#2537)
Even though it has type `String -> a` and thus only a single argument, when `a` is itself a function type, we have to account for additional arguments in `BlackBoxFunction`.
1 parent 49f5bd3 commit fadedce

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

clash-lib/src/Clash/Primitives/Prelude.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ module Clash.Primitives.Prelude
1515

1616
import Data.Either (lefts)
1717
import GHC.Stack (HasCallStack)
18+
import Text.Show.Pretty
1819

1920
import Clash.Core.TermLiteral (termToDataError)
2021
import Clash.Netlist.BlackBox.Types (BlackBoxFunction)
2122
import Clash.Netlist.Types ()
2223

2324
clashCompileErrorBBF :: HasCallStack => BlackBoxFunction
2425
clashCompileErrorBBF _isD _primName args _ty
25-
| [ _hasCallstack
26-
, either error id . termToDataError -> msg
27-
] <- lefts args
26+
| _hasCallstack
27+
: (either error id . termToDataError -> msg)
28+
: _ <- lefts args
2829
= pure $ Left $ "clashCompileError: " <> msg
2930
| otherwise
30-
= pure $ Left $ show 'clashCompileErrorBBF <> ": bad args: " <> show args
31+
= pure $ Left $ show 'clashCompileErrorBBF <> ": bad args:\n" <> ppShow args

0 commit comments

Comments
 (0)