EXPERIMENT: Int return types as data — and the bug that fell out

PREDICTIONS AND RESULTS
  P1 is_int_call's 35 hardcoded names move to data        TRUE
  P2 is_int_name stays -- it is annotation propagation    TRUE
  P3 the dispatch stays -- it is emission                 TRUE
  P4 codegen shrinks ~40 lines                            TRUE  4507 -> 4469
  P5 the design doc's characterisation is WRONG           TRUE
  P6 the moved data also fixes the bug it exposed         TRUE

P5 CORRECTS THE RECORD. el-language-design.md and geometry-vs-code.md both cite
"== lowering to str_eq unless both operand names are in a hardcoded int-name
set -- a literal list of variable names treated as integers" as the paradigm
defect. It is not one. __int_names is populated from TYPE ANNOTATIONS
(param["type"] == "Int"), which is primitive but legitimate type propagation.
The actual defect was is_int_call: 35 hardcoded builtin return types, the same
shape as the temporal 19.

P6 IS A LIVE CORRECTNESS BUG, PRE-EXISTING, NOW FIXED

    let a = str_len("hello")     // no annotation
    let b = str_len("hi")
    let c = a + b                // -> el_str_concat(a, b) on two integers

Verified identical on the pre-change compiler, so not a regression. It compiled
clean, ran, and printed NOTHING where it should print 7. No error at any layer.

The repair is three lines: an unannotated let takes its type from what the
initialiser returns. The return types were already required for dispatch and
were simply never consulted at the binding site. Moving them into data is what
made the gap visible -- reading the code for eight hours did not.

98/98 native + 2 new, 31/31 integration, fixpoint ok.
This commit is contained in:
bigmerge
2026-08-17 09:32:13 -05:00
parent 50425f375d
commit cbef1c1ebb
3 changed files with 71 additions and 40 deletions
+19
View File
@@ -924,3 +924,22 @@ test "compiler-no-longer-emits-prohibition-errors" {
let out: String = compile_capture(src)
assert !str_contains(out, "boundary violation"), "the emitter does not adjudicate"
}
// Int return types drive + dispatch
//
// El has one type, so `a + b` must be dispatched from what the operands ARE.
// The 35 Int-returning builtins moved to signatures.rel; the dispatch stayed,
// because choosing between arithmetic and concatenation is emission.
test "int-returning-builtin-drives-arithmetic-dispatch" {
let src: String = "fn main() { let a = str_len(\"hello\") let b = str_len(\"hi\") let c = a + b println(int_to_str(c)) }"
let out: String = compile_capture(src)
assert str_contains(out, "(a + b)"), "Int + Int is arithmetic"
assert !str_contains(out, "el_str_concat(a, b)"), "and NOT concatenation"
}
test "string-plus-string-still-concatenates" {
let src: String = "fn main() { let s = \"a\" + \"b\" println(s) }"
let out: String = compile_capture(src)
assert str_contains(out, "el_str_concat"), "String + String still concatenates"
}