// IR interpreter — variadic `..Any` indexing inside post-link callback.
//
// `format(fmt, args: ..Any)` lowers to `any_to_string(args[i])` calls.
// The interpreter must be able to read every element of the packed
// `[N x Any]` slice from within a `#run`/post-link callback, not just
// the first two — and not just via JIT.

#import "modules/std.sx";
#import "modules/compiler.sx";

puts :: (s: [:0]u8) -> s32 #foreign libc;

cb :: () -> bool {
    a := format("{}", "x");
    puts("1-arg ok");
    b := format("{} {}", "x", "y");
    puts("2-arg ok");
    c := format("{} {} {}", "x", "y", "z");
    puts("3-arg ok");
    true;
}

configure :: () {
    opts := build_options();
    opts.set_post_link_callback(cb);
}
#run configure();

main :: () { print("rt\n"); }
