Result: partial Files: crates/nikaia-std/src/tools/check_core_places.nika crates/nikaia-std/src/tools/lowered/check_core_places.rs crates/nikaia-std/src/tools/views.nika crates/nikaia-std/src/tools/lowered/views.rs crates/nikaia/tests/it/stored_views.rs tests/compiler/tests/ref_field_from_local.nika tests/compiler/tests/ref_field_from_local.stdout docs/briefs/bugs/b37-1152-ref-field-from-local.md.report.md Commit: views: a ref field takes an owned local by lending it, and a struct read by a free function keeps nothing Body: check_core_places_a_declared_field: a local (or a field read off one) lent to a ref T field (lent_fields, D37) is now a view of the type, not only text, so W { own: l } is W { own: &l } (no NK1106). views.nika: a local struct passed to a free function whose ledger does not keep that parameter (Unit.read_by_free) is read, not handed on (struct_handed_back), and a struct literal handed straight to such a call is no store (descend’s Call arm), so go(l: ref L) building W { own: l } for show(w) is no NK2302. A callee that keeps it (stash(w, v) pushing into a mut Vec) is still NK2302. stored_views::a_view_in_a_local_struct_called_on_keeps_nothing had a row asserting that an empty fn keep(x: ref H) {} keeps; that row now uses a callee that keeps. Part: #1152 Tests: new tests/compiler ref_field_from_local passes –both-settings and fails on the unfixed compiler (NK2302 at go); it stored_views views_kept keeps tethers text_views typecheck result_source text_tiers anonymous_constructors match_patterns 370 ok; the 3 tests/compiler .stderr naming NK2302/NK1106 ok; clippy, fmt clean Deviation: no ref_field_outlives_local test: returning W { own: l } past the local l is not refused by any rule, it reaches rustc (“Cannot return value referencing local variable”); the same rustc error comes on the unfixed compiler for let first: ref L = xs[0]; return W { own: first, k: 1 } and for a name: ref String field given a local, so it is an open gap of the tether, not of this change. Part III NK2303 says such a view is not refused but kept in the caller’s keep. Brief probe text was not in the brief; written from its description. Found: (1) a struct holding a non-text view of a local, handed back, reaches rustc (probe: struct L { n: i64 } struct W { own: ref L, k: i64 } fn make() -> W { let xs = [L { n: 3 }]; let first: ref L = xs[0]; return W { own: first, k: 1 } }), unfixed compiler too; (2) 7ae5b1f1 committed lowered/type_rules.rs that rustc refuses (E0507 at :692, methods bound without ref mut); the shared tree’s emitter (uncommitted emit_core_match.nika #1139 work) writes ref mut methods, which compiles; (3) another agent’s uncommitted copied_views emitter work (emit_expr.nika) in a binary built 03:31 lowers **segment derefs into comptime_tree, emit_calls, emit_exprs, …; I re-lowered with NIKAIA_LOWER_CACHE_SALT using my own binary so the tree builds; none of those files are in this commit Needs: supervisor decision on (1): implement the caller’s keep for a non-text view of a local (NK2303) or refuse it; then the refusal/keep test of #1152 step 1; also (2) for the owner of R3c-d Changelog: A ref T field takes an owned local by lending it, and a struct built from a ref parameter and handed only to a function that does not keep it is no keep (#1152). Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01GFeMqxRbtUMiGVyDMxsvEq Pushed: local 2ea6b8254a1b2341bdc48215ad9e72af1218fe5a

This site is open source. Improve this page.