Repository navigation
hy-check: instantiate generic call return shapes and keep block-exit outer aliases (refs #73, #313) - #1216
Conversation
Prior-Art & First-Reporter Cross-Reference (
|
…xit outer aliases Instantiate generic function and method return shapes and TypeExprs from call-site arguments across single-value and multi-value calls so shallow-copied references, struct field projections, slice element copies, and closure slices cannot escape O5.2 freeze tracking. Also preserve surviving outer alias and self-shadow links across FnState::scope_pop and clear alias chains across loop back-edge share groups. Fixes limitlessprojects#73 Fixes limitlessprojects#313 Sibling-take credit: @Visional-Dev (limitlessprojects#408), @Andrrewss (limitlessprojects#401)
2dd3c74 to
7a9b538
Compare
|
Thanks @sonson0910. Our three generic-call tests ( |
|
Queue-reset sweep: this repo now runs a rolling conveyor, and open PRs This is not a verdict on the work. If this change still matters:
Wildcard holds (verdict window 2026-11-01) and Pareto land candidates are |
Refs #73 (residual generic variants)
Refs #313
What this fixes
The original #73 repros (
alias_holder(h1)andid(m)/id(s)) are already rejected on main (seetests/call_share.rs). This PR closes the generic gaps that are still open, plus one block-exit alias hole:m2 := id(m); m3 := m2; move m; write m3. Main accepted this, and the emitted Go races at runtime (concurrent map writes). It is now rejected with HYB-E3003.h2 := id(h1); inner := h2.m; move h1; write inner. Main accepted this. It is now rejected with HYB-E3003._, m2 := pair_id(1, m); m3 := m2; move m; write m3. Main accepted this. It is now rejected with HYB-E3003.m2 := id(move m); task worker(move m2)is valid. Main rejected it with HYB-E3005. It is now accepted.if true { m := m; alias = m; m = fresh }; task worker(move m); alias[k] = 3. Main accepted this, and the emitted Go races at runtime. It is now rejected with HYB-E3003.FnState::scope_popnow keeps outer alias links and shadow links when a block exits.Implementation
shape.rs: generic type parameters are instantiated at call sites (infer_call_type_shapes,infer_call_type_args,subst_call_type_params,call_result_tys_with_args,call_result_shapes_with_args).loans.rs:value_reads_storage_ofandexpr_has_borrow_shapenow use the instantiated result shapes.model.rs:scope_popkeeps outer aliases and shadow links. Cycles are checked, and the change only makes the checker stricter.freeze.rs: aftercheck_loop_backedgereports, it clears the whole alias chain, so the same chain is not reported twice.Tests
These tests fail on base 7d63d5f and pass with this PR:
generic_call_freeze_73_a(alias chain, struct projection)generic_call_freeze_73_b(owned move chain, the E3005 false reject)generic_multi_return_73scope_pop_outer_alias_313(shadow sub-case)loop_backedge_range_vars_313passes on main as well. It is a regression guard and does not prove a fix.cargo test -p hy-check: 1369 passed, 0 failed.Out of scope / known limitations
b := box[map]{val: m}; m2 := unbox(b)) is not handled. It is still accepted and needs a separate issue. Its test case was removed from this PR.wrap_slice(f)) andcopy(dst, id_slice(src))cases from the tests. Main already rejects both, so they are not fixes from this PR.