feat(lang): 0.S - a reference out of a read-only state is read-only (named so), a program's type named like the runtime's is refused (PadButton), tests for both, the migrate case covers lets; changeset

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 16:17:03 +03:00
parent 02448e176c
commit c167ecc714
10 changed files with 13858 additions and 13042 deletions

View file

@ -81,6 +81,10 @@ function ck_write_check(t: Node, what: pointer) -> void {
mg_need(g_mg_cur, mg_state_named(ck_ro_st[li]), true) # 0.S2: it becomes `mut`
return
}
if ck_is_ro(li) and li < len(ck_ro_st) and ck_ro_st[li] != null and not (ck_ro_st[li] == ck_tys[li]) {
ck_err("state", t, `{what}: {r.s} holds part of a read-only {ck_ro_st[li]}; take the state as mut {ck_ro_st[li]} to change it`)
return
}
if ck_is_ro(li) {
ck_err("state", t, `{what}: {r.s} is read-only here ({r.s}: {ck_tys[li]}); take it as {r.s}: mut {ck_tys[li]} to change it`)
}

View file

@ -208,9 +208,29 @@ function ck_runtime_shadows() -> void {
let u = ck_fn(d.s)
if u != null and u != d { ck_err("shadow", u, `{d.s} is also a function of the engine runtime ({d.file}); choose another name`) }
}
# a type the runtime declares - `property PadButton` beside its `enum PadButton` compiled,
# and the two layouts met in the IR
if ck_type_kind(d) != "" {
var k = 0
while k < g_prog_user_end and k < len(prog) {
let o = prog[k]
if ck_type_kind(o) != "" and (o.s == d.s) {
ck_err("shadow", o, `{d.s} is the runtime's {ck_type_kind(d)} ({d.file}); choose another name for this {ck_type_kind(o)}`)
}
k += 1
}
}
r += 1
}
}
function ck_type_kind(d: Node) -> pointer {
if d.kind == N_ENUM { return "enum" }
if d.kind == N_COMP and d.uns == 2 { return "state" }
if d.kind == N_COMP { return "property" }
if d.kind == N_STRUCT { return "record" }
if d.kind == N_EVENT { return "event" }
return ""
}
function ck_hooks(hs: []Node) -> void {
var i = 0
while i < len(hs) {

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff