fix(migrate): 0.R5 - a state an argument to a C function comes out of keeps the mutability it was declared with, so --tighten leaves the mut on a wrapper writing through a native handle (phys_force) and does not add one to a query that reads through one

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-27 04:23:11 +03:00
parent b247603b7e
commit 67d8079c47
4 changed files with 13002 additions and 12636 deletions

View file

@ -239,6 +239,7 @@ function ck_call_named(e: Node, name: pointer) -> pointer {
let x = ck_extern(name)
if x != null {
ck_raw(e, `the C function {name}`)
ck_extern_writes(e)
ck_extern_arg = true
let xt = ck_call_fn(e, name, x)
ck_extern_arg = false

View file

@ -137,3 +137,18 @@ function ck_state_args(e: Node, f: Node) -> void {
i += 1
}
}
# a C function is handed what it may change: a state an argument comes out of keeps the mutability
# it was declared with, so --tighten leaves the mut on a wrapper writing through a native handle
function ck_extern_writes(e: Node) -> void {
var i = 0
while i < len(e.kids) {
var a = e.kids[i]
if a.kind == E_FINIT { a = a.a }
let r = ck_chain_root(a)
if r != null {
let li = ck_local(r.s)
if li >= 0 and li < len(ck_from_st) and ck_from_st[li] != null and not ck_is_ro(li) { mg_local_write(ck_from_st[li]) }
}
i += 1
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff