It’s not so much I have reservations against it, it’s more like it looks like it wouldn’t do anything. I can’t tell what the purpose is, let alone have any reservation against it. Maybe an example of a hypothetical AOT compilation script will make clear what I mean? Let’s imagine Base.precompile can do the whole compilation process, and we have a stricter version AOTcompile that throws an error at any type instability:
f(x) = 2*x
g(x::Vector{Any}) = x[1]
AOTcompile(f, (Int,) ) # e.g. f(1), stable
AOTcompile(g, (Vector{Any},) ) # e.g. g(Any[0]), InstabilityError
By your proposal, we can annotate methods to assert type stability. But I don’t expect anything to change:
@typestable f(x) = 2*x
@typestable g(x::Vector{Any}) = x[1]
# writing it for g is obviously wrong, but nothing is stopping me
AOTcompile(f, (Int,) ) # e.g. f(1), stable
AOTcompile(g, (Vector{Any},) ) # e.g. g(Any[0]), InstabilityError
I think if there’s anything wrong with my understanding, you could point out how this should act differently from what I expect.