From 0432ac6aefccbc5a9af25bd4ed2d4451611c4ff4 Mon Sep 17 00:00:00 2001 From: zinc Date: Thu, 15 Oct 2026 14:57:42 +0330 Subject: analyzer: an outer owner moved into a deeper container can take it back (loop-built lists); block-end frees name the owner (why 9) in messages and LSP related info --- src/compiler/base.zc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/compiler/base.zc') diff --git a/src/compiler/base.zc b/src/compiler/base.zc index 7e4b5bc..de699aa 100644 --- a/src/compiler/base.zc +++ b/src/compiler/base.zc @@ -980,9 +980,16 @@ int cerr(char* msg) { } // how an owner ended, from end_owner's record: the use, the owner, what ended it and where. // "r: used after it was given away; r borrows t, and t was freed on line 5 (t declared on line 4)" -int ended_message(char* use, word info, char* root, int cause) { +int ended_message(char* use, word info, char* root, int cause, int own) { char* owner = root; int why = 0; char* whom = 0; if (info) { owner = info[0]; why = info[3]; whom = info[4]; dg_related(info[5], info[1], why, owner); } + if (why == 9) { + rt.put_s(use); rt.put_s(": "); + if (rt.eq_w(use, owner)) rt.put_s("was freed"); + else { if (own) rt.put_s("belongs to "); else rt.put_s("borrows from "); rt.put_s(owner); rt.put_s(", which was freed"); } + rt.put_s(" at the end of its block (line "); rt.put_n(cause & 0xFFFFFF); rt.put_c(')'); + return 0; + } rt.put_s(use); rt.put_s(": used after it was given away; "); if (!rt.eq_w(use, owner)) { rt.put_s(use); rt.put_s(" borrows "); rt.put_s(owner); rt.put_s(", and "); } rt.put_s(owner); @@ -1008,7 +1015,7 @@ int cerrn(int i, char* msg) { if (!info && local_end_info) info = local_end_info[root]; if (info) cause = info[2]; else if (local_ended) cause = local_ended[root]; } - if (cause && !panic && !dry) { errat(); dg_place(lreadpos[i]); ended_message(lname[i], info, lname[root], cause); errend(); } + if (cause && !panic && !dry) { errat(); dg_place(lreadpos[i]); ended_message(lname[i], info, lname[root], cause, lown[i]); errend(); } else serrn(lname[i], msg); } return 0; -- cgit v1.2.3