From 0a87c4663fc52bf60f3d440200b3b3ad6b39bd3e Mon Sep 17 00:00:00 2001 From: zinc Date: Thu, 15 Oct 2026 09:48:10 +0330 Subject: analyzer: use-after-end messages name the borrower, the owner and how the owner ended (freed, moved, .d parameter, push, global, reassignment), with fixtures --- docs/SPEC.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/SPEC.md b/docs/SPEC.md index 06ee11c..923e24b 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -884,7 +884,7 @@ char* tail(char* s) { return s + 1; } char* b = rt.new(4); b[0] = 'a'; b[1] = 'b'; b[2] = 0; char* t = tail(b); rt.free(b); -rt.put_s(t); // error: t: used after it was given away; owner b was transferred on line N (declared on line M) +rt.put_s(t); // error: t: used after it was given away; t borrows b, and b was freed on line N (b declared on line M) ``` placing `rt.free(b)` after the use is accepted (the alias's last use precedes the transfer). @@ -948,7 +948,7 @@ rt.outbuf = saved; each fixture in `tests/errors/` starts with `// expect: MESSAGE`; the messages that the analyzer produces are (X is a variable name): -- X: used after it was given away; owner Y was transferred on line N (declared on line M) +- X: used after it was given away; X borrows Y, and Y was HOW on line N (Y declared on line M), or, for the owner itself, X was HOW on line N (declared on line M). HOW is one of: freed, freed by reassigning it, given to F's .d parameter, moved into Z, stored into Z, pushed into an array, stored in a global or untracked memory, returned, or transferred when the analyzer has no more specific cause - X: owned object is never used - X: still owns an object; overwriting it would leak it - X: is an owned object and can't be copied into another variable -- cgit v1.2.3