checker: a function named like a built-in a call always takes is refused at its declaration - function words(st, k) compiled and every call became words(n) with a pointer for n (invalid IR, far from the cause); the table is selfhost/check/check_builtins.ludic, emit_call's built-ins no find_fn guard lets a declared function take, and ludic-dev syntax --check holds it to emit_call both ways; every other built-in (buffer, floats, double, ...) yields to a declared function in the checker as it already did in codegen. string_temps' keep and cross_heap_test's keep renamed (hand, keep_cell); rejected/builtin_call_name and functions/builtin_yield with their cases (added, not run); reseeded, bootstrap-cfree fixpoint holds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-30 01:10:24 +03:00
parent 26b986de5b
commit d4df925b8f
13 changed files with 14830 additions and 13043 deletions

View file

@ -0,0 +1,23 @@
# check_builtins.ludic — the names a call always takes as the compiler's own, whatever the program
# declares: emit_call's built-ins that no `find_fn` guard lets a declared function take. A function
# so named is refused (ck_runtime_shadows) - a call would never reach it: a `words(st, k)` helper
# once compiled as words(n) with a pointer for its size. Every other built-in yields to a declared
# function, in the checker as in codegen; `ludic-dev syntax --check` holds this table to emit_call.
function is_call_builtin(name: pointer) -> bool {
if (name == "apply") or (name == "assert") or (name == "bytes") or (name == "data_of") { return true }
if (name == "expect") or (name == "expect_eq") or (name == "expect_near") or (name == "fixed") { return true }
if (name == "floor") or (name == "intern") or (name == "is_owner") or (name == "is_server") { return true }
if (name == "keep") or (name == "key") or (name == "len") or (name == "load") { return true }
if (name == "local_id") or (name == "net_poll") or (name == "net_pump") or (name == "net_send") { return true }
if (name == "owner") or (name == "panic") or (name == "print") or (name == "push") { return true }
if (name == "quit") or (name == "save") or (name == "self") or (name == "serialize") { return true }
if (name == "set_local_id") or (name == "set_owner") or (name == "set_role") or (name == "string") { return true }
if (name == "sync_size") or (name == "tick_fixed") or (name == "tick_render") or (name == "view") { return true }
if (name == "words") or (name == "world_attach_dyn") or (name == "world_count") or (name == "world_detach_dyn") { return true }
if (name == "world_field_count") or (name == "world_field_id") or (name == "world_field_name") or (name == "world_field_type") { return true }
if (name == "world_get") or (name == "world_has") or (name == "world_kind") or (name == "world_load") { return true }
if (name == "world_model_id") or (name == "world_prop_count") or (name == "world_prop_id") or (name == "world_prop_name") { return true }
if (name == "world_query_next") or (name == "world_register_prop") or (name == "world_save") or (name == "world_set") { return true }
if (name == "world_size") or (name == "world_spawn") { return true }
return false
}

View file

@ -231,6 +231,15 @@ function ck_call_named(e: Node, name: pointer) -> pointer {
return "?"
}
if ck_raw_builtin(name) { ck_raw(e, `{name}()`) }
# a built-in no call always takes (not is_call_builtin) yields to a function the program declares,
# as codegen's does: the checker once typed a `buffer` helper as buffer(n) while codegen called it
if not is_call_builtin(name) {
let uf = ck_fn(name)
if uf != null {
ck_vis(uf, name, e)
return ck_call_fn(e, name, uf)
}
}
let bt = ck_builtin(e, name)
if bt != null { return bt }
let f = ck_fn(name)

View file

@ -212,7 +212,7 @@ function ck_runtime_shadows() -> void {
var u = 0
while u < g_prog_user_end {
let d = prog[u]
if d.kind == N_FN and (is_intrinsic(d.s) or is_intrinsic2(d.s)) { ck_err("shadow", d, `{d.s} is a built-in of the compiler, and a call to it would never reach this function; choose another name`) }
if d.kind == N_FN and (is_intrinsic(d.s) or is_intrinsic2(d.s) or is_call_builtin(d.s)) { ck_err("shadow", d, `{d.s} is a built-in of the compiler, and a call to it would never reach this function; choose another name`) }
u += 1
}
var r = g_prog_user_end

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff