Repository navigation
Borrow checker reborrows, SMP shadowing fix, split large source files - #2
Merged
Merged
Conversation
…ter-free - Add CMakePresets.json, GitHub Actions CI, issue/PR templates, CONTRIBUTING, .editorconfig and .gitattributes - Move ARCHITECTURE.md and BUILD.md to docs/; move test registration into tests/CMakeLists.txt - Add UINX_WARNINGS_AS_ERRORS and UINX_ENABLE_SANITIZERS options - Remove stale MANIFEST.sha256 (35 of 159 entries no longer matched) and the checked-in verification transcripts that contradicted their own README - Fix heap-use-after-free in Type::operator= when assigning from an owned pointee (found by ASan), and a -Wconversion warning in codegen - Apply clang-format to files that had drifted Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018uUuRXQcBduAQvVUcJYkWz
Pure move, no behavior change. borrow.cpp (1894 lines), sema.cpp (1795) and codegen.cpp (1881) are split by responsibility; helpers formerly in anonymous namespaces move to src/*_internal.hpp. LLVM IR and diagnostics for all 56 examples/tests are byte-identical before and after. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018uUuRXQcBduAQvVUcJYkWz
…erences
- Passing a mutref place to a mutref parameter reborrows it for the call
instead of moving it; reusing it in the same argument list conflicts, and
calls whose result may carry a reference keep the move semantics.
- 'borrow [mut] deref r' reborrows through r: the new reference inherits r's
origins without conflicting with r's own loans, and r and every ancestor stay
frozen while the reborrow is live. Reference parameters are tracked through
an external origin.
- 'deref r = v' is now checked against loans on r and rejects a moved r.
- mutable_ref_move now uses a real move ('val second = first'); consuming the
same mutref twice is a reborrow and valid, as in Rust.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018uUuRXQcBduAQvVUcJYkWz
- E0363 no longer fires for a local or parameter that shadows a mutable global (name resolution via HIR instead of string lookup). - The call-graph and shared-state checks used two hand-copied AST traversals; both now use for_each_child_expr/walk_stmt_exprs (sema_smp.cpp 372 -> 217 lines). - Split mir.cpp into lowering, statement, expression and optimizer units. - Tests for shadowing and for walker coverage (loop condition, cast). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018uUuRXQcBduAQvVUcJYkWz
# Conflicts: # CHANGELOG.md # src/codegen.cpp # src/mir.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
borrow.cpp,sema.cpp,codegen.cppandmir.cppinto 21 focused translation units (largest now ~650 lines), with shared helpers insrc/*_internal.hpp. LLVM IR for all 57 examples and tests is byte-identical before and after.mutrefis passed to amutrefparameter (inc(r); inc(r)); reusing it in the same argument list conflicts, and calls whose result may carry a reference keep the move semantics;borrow [mut] deref rreborrows, including nested ones and ones through reference parameters; the parent stays frozen while the reborrow is live;deref r = v) are now checked against live loans and moves (previously unchecked).E0363); the call-graph and shared-state checks now share one AST traversal instead of two hand-copied ones (sema_smp.cpp372 -> 217 lines).consume(first); consume(first)on amutrefis now accepted (a reborrow, as in Rust).tests/safety/borrow-fail/mutable_ref_move.uxnow uses a real move (val second = first) and still fails withE0400.Checklist
ctest --preset cipasses locally (GCC 13,-Werror, 20/20)ctest --preset asanpasses locally (20/20)clang-formatis clean (format-check)tests/CHANGELOG.mdNot in this PR: lock-guarded data types, init-once globals, and method calls on generic-bounded receivers (design work, noted for follow-up).
Generated by Claude Code