diff options
| author | 2026-10-15 17:50:10 +0330 | |
|---|---|---|
| committer | 2026-10-15 17:50:10 +0330 | |
| commit | 251b0212f626d0f92eda51906d353712ef4a63b8 (patch) | |
| tree | 4f0e0b0ee6b0f6d0671261a46bb2bcd15ef0f59c /tests/drivers | |
| parent | merge work/actors: wasm seed bootstrap (seed/MANIFEST), shared copy-on-write ... (diff) | |
| parent | prescan: guess an owned return only from a local declared from new/heap, not ... (diff) | |
merge work/demo-fixes: analyzer ownership fixes (back links, loop-built lists, .u inference), Io.print any args, block-end borrow messages
Diffstat (limited to 'tests/drivers')
| -rw-r--r-- | tests/drivers/borrow_diag_test.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/drivers/borrow_diag_test.js b/tests/drivers/borrow_diag_test.js index 93a7561..027b978 100644 --- a/tests/drivers/borrow_diag_test.js +++ b/tests/drivers/borrow_diag_test.js @@ -70,4 +70,13 @@ assert.strictEqual(d.relatedInformation[0].message, 'owner t was freed here'); text = 'include rt;\nchar* first(char* a, char* b) borrows a;\nchar* first(char* a, char* b) { return b; }\nfn main() { return 0; }\n'; d = same(text, 'borrows clause'); assert.match(d.message, /returns a borrow of b/); +// a borrow that outlives the block its owner was freed at the end of +text = 'include rt;\nstruct node { int v; node* next; };\nfn main() {\n\tnode* second;\n\t{\n\t\tnode* head = rt.new(node);\n\t\thead.next = rt.new(node);\n\t\tsecond = head.next;\n\t}\n\treturn second.v;\n}\n'; +d = same(text, 'block end'); +assert.match(d.message, /^second: borrows from head, which was freed at the end of its block \(line 9\)$/); +assert.deepStrictEqual(d.range.start, at(text, 'second.v'), 'the range is the conflicting use'); +assert.ok(d.relatedInformation && d.relatedInformation.length === 2, JSON.stringify(d)); +assert.strictEqual(d.relatedInformation[0].message, 'owner head was freed at the end of this block'); +assert.strictEqual(d.relatedInformation[1].message, 'owner head is declared here'); +assert.deepStrictEqual(d.relatedInformation[1].location.range.start, at(text, 'head =')); console.log(`ok borrow diagnostics: ${checks} cases match zy, with ranges and related owner places`); |
