feat(lang): L4 type checker between parse and emit
selfhost/check/ walks every function, the entry, tests, globals' initializers and @On listeners with real scopes, and refuses mixed number kinds, text and numbers, two record types, mismatched slices and fn types, wrong argument counts, wrong returns and wrong push elements - every mix-up at once, each at its line. LUDIC_CHECK_REPORT=1 lists them by category. pointer stays untyped (L7's). What it found is fixed: render3d's HDR scan calling the float-bits extern f_lt with floats; ludic.shooter's right-stick aim overflowing past half a push; prof.ludic storing longs in []int; extern arguments now coerced to their parameters. Text-returning runtime functions say string; Assets.ready says bool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0677aee93f
commit
57b66bdf47
52 changed files with 27005 additions and 11844 deletions
11
examples/rejected/every_error.ludic
Normal file
11
examples/rejected/every_error.ludic
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# L4: every mix-up in a program is reported at once, not only the first
|
||||
program EveryError {
|
||||
function half(n: int) -> int { return n / 2 }
|
||||
function name() -> int { return "seven" }
|
||||
entry {
|
||||
let on = true
|
||||
print(on + 1)
|
||||
print(half(1, 2))
|
||||
print(name())
|
||||
}
|
||||
}
|
||||
10
examples/rejected/float_into_int.ludic
Normal file
10
examples/rejected/float_into_int.ludic
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# L4: a float computed into an int slot is refused - write int(x)
|
||||
program FloatIntoInt {
|
||||
numbers float
|
||||
entry {
|
||||
let speed: float = 3.2
|
||||
var metres: int = 0
|
||||
metres = speed * 2.0
|
||||
print(metres)
|
||||
}
|
||||
}
|
||||
9
examples/rejected/record_as_text.ludic
Normal file
9
examples/rejected/record_as_text.ludic
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# L4: a record is not text; say which of its fields is meant
|
||||
program RecordAsText {
|
||||
property Trail { name: string = "Crater Lake" }
|
||||
function sign(s: string) -> string { return "To " + s }
|
||||
entry {
|
||||
let t = new Trail
|
||||
print(sign(t))
|
||||
}
|
||||
}
|
||||
10
examples/rejected/record_mixup.ludic
Normal file
10
examples/rejected/record_mixup.ludic
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# L4: one record is not another, whatever their fields
|
||||
program RecordMixup {
|
||||
property Door { open: bool = false }
|
||||
property Key { cut: int = 0 }
|
||||
entry {
|
||||
let k = new Key
|
||||
let d: Door = k
|
||||
print(d.open)
|
||||
}
|
||||
}
|
||||
7
examples/rejected/text_plus_number.ludic
Normal file
7
examples/rejected/text_plus_number.ludic
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# L4: text joins text only; a number is written with string(n) or a template
|
||||
program TextPlusNumber {
|
||||
entry {
|
||||
let n = 3
|
||||
print("apples: " + n)
|
||||
}
|
||||
}
|
||||
5
examples/rejected/wrong_arity.ludic
Normal file
5
examples/rejected/wrong_arity.ludic
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# L4: a call gives as many arguments as the function has parameters
|
||||
program WrongArity {
|
||||
function area(w: int, h: int) -> int { return w * h }
|
||||
entry { print(area(3)) }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue