Repository navigation
Preserve nil map zero values and write panics - #174
Conversation
|
Sorry @tylerlaprade, this account has used its review budget of 1,500,000 diff characters for the last 7 days. You can request another review in 2 days and 5 hours by commenting |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 21 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's GuideData structuresAdd per-file and per-function tracking for uninitialized local map variables so later write translation can distinguish nil zero values from initialized maps.
ImplementationPreserve nil zero values for local maps and generate nil-safe reads, ranges, and Go-compatible panics for writes to tracked nil maps.
TestsAdd focused assertions for nil-map declarations, write evaluation order and panics, and nil-tolerant field reads and ranges.
Regenerate Rust fixture snapshots affected by the nil-tolerant map access and zero-value translation changes.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Fixtures whose generated code the merged translator changes: anonymous_structs_nested blank_assignment_of_nil_values blank_assignment_of_nil_values_goroutines defer_named_return_map_capture goroutine_panic_recover map_comma_ok_value_copy map_comma_ok_value_copy_goroutines map_nil_assignment map_range_key_value_reuse method_closure_receiver_capture pointer_receiver_deref_assignment range_loops slice_elem_struct_ptr_index Agent: claude-chat Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TkCXVghVg3khqYkpQSWyEM
Reproduction
Go prints
true 0 0 false, thenassignment to entry in nil map. Master allocated an emptyBTreeMap, printedfalse 0 0 false, accepted the write, and recovered<nil>.A zero-valued struct map field exposed the related read boundary: plain lookup, comma-ok lookup, and range unwrapped
Noneinstead of producing Go's zero/empty behavior.Change
Unnamed local map declarations without an initializer now keep the Go nil zero value. Their plain and compound writes still evaluate keys and values first, then raise Go's runtime message if the map remains nil. Named maps retain their existing wrapper representation.
Map-field plain lookup, comma-ok lookup, and range now use the nil-tolerant handle path. Initialized map fields continue to use the same value-copy behavior.
Differential evidence
The fixture compares actual Go 1.24 and translated Rust 1.100 output and exit behavior for:
make(map...)control;Eleven selected differential programs pass, covering nil and initialized map selectors, named-map fields, promoted pointer map fields, ordinary maps, source-translated
path/filepath, hostname, andexec.ExitError. This is representative coverage, not a percentile.The Go unit-test ratchet is unchanged at its 33 documented failures. Focused map/evaluation-order/value-copy tests,
go vet ./go, andgit diff --checkpass.The initial CI run found two new unit-ratchet entries. Commit
0985f66fixes the named-map initialization regression and updates the selector value-copy assertion to the new nil-tolerant path; both reproduce and pass locally.Known boundary
Go recovers the nil-map assignment payload as an
error; translated Rust currently recovers a string. That pre-existing dynamic-type transport gap is tracked separately in DEV-73 / PR #97.Linear: DEV-68 (DEV-128 was closed as a duplicate)
— Codex
Summary by Sourcery
Preserve Go nil-map semantics across local declarations, field access, reads, ranges, and writes.
New Features:
Bug Fixes:
Tests: