Open christiaanb opened 2 years ago
I'd like to work on this. @alex-mckenna already gave me some pointers for where to look and how to write a test case for it.
For reference, we were also a bit surprised that errorX
does not have a NOINLINE
pragma (which wouldn't avoid this issue in general, but might still be a good idea?).
For reference, we were also a bit surprised that
errorX
does not have aNOINLINE
pragma (which wouldn't avoid this issue in general, but might still be a good idea?).
That's bottoming values never get an unfolding in the interface file, so it's implicitly NOINLINE
across modules; see also https://github.com/clash-lang/clash-compiler/commit/e5faf05d3cce867d1f4a0f58a15901455d9062f3
Ah, I forgot we checked for bottoming in clash-ghc
. This all makes sense now
Something that just occurs to me: since
errorX
is justthrow (XException ...)
it presumably always gets left alone by the simplifier, but what if a user writesthrow (XException "Boom")
directly? Does this then fail to be identified as an undefined X primitive and get identified as a normal undefined primitive?_Originally posted by @alex-mckenna in https://github.com/clash-lang/clash-compiler/pull/2153#discussion_r841422887_
It is "left alone" by the evaluator because there's no evaluator rule for
throw
, meaning any expression where the result ofthrow
is forced, the evaluator collapses toNothing
.When/if we ever do get to implement the evaluator rule for
throw
, we should probably evaluate to aClash.Normalize.Primitive.undefinedX
value when an XException is thrown, andClash.Normalize.Primitive.undefined
otherwise.