You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Facade: an fn item describing a producer also renders a safe lend method that exposes the raw out slot (Database.sqlite3_prepare_v2(…, ppStmt: *mut *mut sqlite3_stmt, …)) #1500
Spec: §16.2b.3/§16.2b.4 (a resource's producer is its constructor), §16.2b.5 (a lend method borrows the resource), ruling §9 (never half-model).
Repro (modeled-C stage 6 branch, real sqlite3.h via with get c.sqlite3):
c facade sqlite:
resource Database wraps *mut sqlite3
from sqlite3_open(out param 1)
drop sqlite3_close
ok SQLITE_OK
resource Statement wraps *mut sqlite3_stmt
from sqlite3_prepare_v2(out param 3)
drop sqlite3_finalize
borrows param 0
fn sqlite3_prepare_v2
lend
The fn sqlite3_prepare_v2 / lend item is needed: without it the producer is "still a raw call after the facade covers its out parameter" (pzTail: const char ** is an undescribed raw pointer). With it, besides the constructor Statement.sqlite3_prepare_v2(db: &Database, zSql: str, nByte: c_int, pzTail: *mut *const i8) -> (c_int, Option[Statement]), the stage-4 lend renderer also emits a safe method on the parent:
(with check --dump-typed). It hands C the caller's own out slot, so the statement it produces is an unowned raw handle that nothing finalizes: a second call surface for the producer that bypasses the resource (§16.2b.4: "one call surface per production form", D59) and leaks.
Expected: an fn item that describes a resource's producer (a from/init of any resource) is not also presented as a lend method; its lend (and preserves, etc.) describes the parameters of the constructor only. Or the facade needs a way to describe pzTail without lend — a ruling question for presentation (stage 8).
Found while implementing modeled-C stage 6; not fixed there (lend-method presentation is stage 4/8).
Already fixed on main by #1601 (modeled-C stage 8: facade_render_lend_item skips a producer that from covers, via facade_render_is_resource_op). Verified: the issue's facade renders the constructor only. A regression test pinning it is on the ruled-fixes stack layer.
Activity
ehartford commentedon Sep 26, 2026
Already fixed on main by #1601 (modeled-C stage 8: facade_render_lend_item skips a producer that
fromcovers, via facade_render_is_resource_op). Verified: the issue's facade renders the constructor only. A regression test pinning it is on the ruled-fixes stack layer.tests: pin that a producer's `lend` fn item renders its constructor o…
tests: pin that a producer's `lend` fn item renders its constructor o…
tests: pin that a producer's `lend` fn item renders its constructor o…
tests: pin that a producer's `lend` fn item renders its constructor o…
tests: pin that a producer's `lend` fn item renders its constructor o…
Spec-ruled fixes: Some(place) borrows for Option[&T], module globals …