Infinite recursion error in tutorial code

I’m trying to work through the tutorial Clash.Tutorial , and I’m encountering the following issue when trying to run :verilog or :vhdl after adding the test-bench segment:

*** Exception: Hit specialization limit 20 on function `c$MAC.testBench_done_go[17281]'. The function `c$MAC.testBench_done_go[17281] :: GHC.Prim.Addr#[3674937295934324738] -> GHC.Types.List[3674937295934324788] GHC.Types.Char[3674937295934324752] -> GHC.Types.List[3674937295934324788] GHC.Types.Char[3674937295934324752]' is most likely recursive, and looks like it is being indefinitely specialized on a growing argument.

Is there an obvious fix for this? I’ve written literally no new code at this point - I tried copy-pasting example code from other tutorials as well and all had this issue - but I’ve been able to find basically no information on it. I did find this issue report ( Certain test bench inlining causes Clash to enter infinite loop · Issue #1796 · clash-lang/clash-compiler · GitHub ) but I don’t think it’s the issue here - I added NOINLINE to both the testbench and toplevel and this made no difference to the issue.

This is caused clash getting confused by some of GHC’s internal string handling functions.

I’ll open an issue on this to try to get this fixed.

But for you an easy way to avoid this problem is to not generate you HDL from inside of clashi, but on the command line with clash instead.

In the same way you ran clashi (whether this was with cabal or with stack) run clash with the -–verilog or -–vhdl option instead.

In case you get error from cabal/stack that that option isn’t recognized, you have to put an extra –- option before it, this will tell cabal/stack that the following options aren’t meant for them and should be passed to clash instead.

That seems to be working. Thanks!