Interesting, I hadn't thought of that use case. I think it's possible to make rules that allow that to happen. For example:
- Compile-time calls to external functions only work if the callee is
@compilerEvaluable
. - A
@compilerEvaluable
function can only call other@compilerEvaluable
functions, even if the caller and callee are internal. @compilerEvaluable
always impliesinlinable
.- However, compile-time calls to same-module functions work on non-annotated functions. (e.g. a module can do
#assert(foo())
whenfoo
is defined in the same module, even iffoo
is not annotated).
(1), (2), and (3) guarantee that the transitive call graph of any compile-time call to an external function has SIL available. (4) supports the use-case that you mention.
Do those rules sound reasonable, easy-to-understand, etc?
I think my only motivation was that I wasn't thinking about the purely-internal use case :) Thanks for pointing it out!
Are the rules that I wrote above along the lines of what you are thinking?