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:
parent
26b986de5b
commit
d4df925b8f
13 changed files with 14830 additions and 13043 deletions
11
examples/functions/builtin_yield.ludic
Normal file
11
examples/functions/builtin_yield.ludic
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# builtin_yield.ludic - a built-in that a declared function may take (buffer, floats, double, ...)
|
||||
# yields to it in the checker as in codegen: this `buffer` is the program's own, returning text.
|
||||
#
|
||||
# Prints: ab 4
|
||||
program BuiltinYield {
|
||||
function buffer(a: string, b: string) -> string { return a + b }
|
||||
entry {
|
||||
let s = buffer("a", "b")
|
||||
print(`{s} {len(floats(4))}`)
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
# has been used, and one that IS held - in a variable, handed to a function, a function's result -
|
||||
# is not. Prints 1 2 3 4 5 6 7 and `grew 0` (the heap is read on the Mac; 0 elsewhere).
|
||||
program StringTemps {
|
||||
function keep(s: string) -> string { return s }
|
||||
function hand(s: string) -> string { return s }
|
||||
function tag(i: int) -> string { return `t{i}` }
|
||||
|
||||
# every shape of throwaway text, compared against itself built another way: nothing survives
|
||||
|
|
@ -29,7 +29,7 @@ program StringTemps {
|
|||
let n = string(-42)
|
||||
let t = n + "!" + n
|
||||
if n == "-42" and t == "-42!-42" { print(2) }
|
||||
let k = keep(a + "+" + b)
|
||||
let k = hand(a + "+" + b)
|
||||
let k2 = k + "=" + k
|
||||
if k == "dir+file" and k2 == "dir+file=dir+file" { print(3) }
|
||||
var acc = ""
|
||||
|
|
@ -37,7 +37,7 @@ program StringTemps {
|
|||
if acc == "0,1,2,3," { print(4) }
|
||||
if string(0) == "0" and string(2147483647) == "2147483647" and `{long(9000000000)}` == "9000000000" { print(5) }
|
||||
let nested = `a{`b{1 + 1}c`}d`
|
||||
# a function's result is its caller's to keep (keep() hands back its own argument), so only
|
||||
# a function's result is its caller's to keep (hand() hands back its own argument), so only
|
||||
# the text built round it goes
|
||||
if nested == "ab2cd" and "[" + tag(3) + "]" == "[t3]" { print(6) }
|
||||
var bad = 0
|
||||
|
|
|
|||
8
examples/rejected/builtin_call_name.ludic
Normal file
8
examples/rejected/builtin_call_name.ludic
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# builtin_call_name.ludic - a function named like a built-in a call always takes is refused at its
|
||||
# declaration: every call to `words` is words(n), n zeroed ints, so this helper would never run (a
|
||||
# pointer became its size). (Rejected on purpose: tools/ludic-cli/test.ludic.)
|
||||
program BuiltinCallName {
|
||||
function words(n: int, k: string) -> string { return k }
|
||||
function keep(s: string) -> string { return s }
|
||||
entry { print(words(1, keep("x"))) }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue