seam refusal + control tests: a runtime binding can short-circuit

Prediction 3 was FALSE. I expected refusal to be impossible through the seam
because the entry indirection discarded its return. One line:

    { el_val_t __s = el_seam_run(EL_STR(f), 0, 0); if (__s) return __s; }

work() returns 7; bound to a refusing construct AFTER the build it returns 42.
So three of the five compile-time kinds are runtime-bindable: entry injection,
exit injection, and refusal. wraps_body needs invocation control and
prohibits_outside is compile-time by nature.

104/104 native compiler tests pass.
This commit is contained in:
bigmerge
2026-08-17 08:40:10 -05:00
parent 35b07bade2
commit 886626a64e
2 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -3208,7 +3208,7 @@ fn cg_entry_seam(stmt: Map<String, Any>, fn_name: String) -> Void {
// RUNTIME SEAM: codegen cannot know which constructs will be bound to this
// fn after the binary exists, so the indirection is unconditional. What
// applies is resolved at execution against a table written later.
emit_line(" el_seam_run(EL_STR(" + c_str_lit(fn_name) + "), 0, 0);")
emit_line(" { el_val_t __s = el_seam_run(EL_STR(" + c_str_lit(fn_name) + "), 0, 0); if (__s) return __s; }")
let gdl = stmt["decorators"]
let n_gdl: Int = native_list_len(gdl)
let gi = 0
+21
View File
@@ -903,3 +903,24 @@ test "seeded-vbd-prohibition-still-enforced" {
let out: String = compile_capture(src)
assert str_contains(out, "may only be called from an @manager fn"), "the compiled-in core prohibition survives being declared rather than branched"
}
// Runtime seam
//
// CONTROL for the finding that a crossing can be resolved at execution rather
// than at emission. Codegen emits one unconditional indirection per fn; which
// constructs apply is read from a table written after the binary exists.
test "seam-indirection-emitted-on-every-fn" {
let src: String = "fn a() -> Int { return 1 }\nfn b() -> Int { return 2 }"
let out: String = compile_capture(src)
assert str_contains(out, "el_seam_run(EL_STR(\"a\"), 0, 0);"), "fn a carries the indirection"
assert str_contains(out, "el_seam_run(EL_STR(\"b\"), 0, 0);"), "fn b carries the indirection"
}
test "seam-emitted-without-any-decorator" {
// The point of the seam: source need not mention a construct at all.
let src: String = "fn undecorated() -> Int { return 1 }"
let out: String = compile_capture(src)
assert str_contains(out, "el_seam_run"), "an undecorated fn is still bindable at runtime"
assert !str_contains(out, "engram_boundary_beat"), "and nothing is inlined for it"
}