Repository navigation
Compile 2-D grids: string(row) of a [][]rune row, and make([][]T, n) - #215
Conversation
Grid programs, such as game boards and matrices, hit three translator bugs
(DEV-159):
- string(row) for a row of a [][]rune or [][]byte borrowed the row as a
cell, and did not compile (E0599). A row, as board[i] or as the value
of a range over board, is a bare slice, and is now read as one.
- make([][]T, n) wrote its rows as Vec::nil(), with no element type. When
nothing else pinned the row type down, the declaration did not compile
(E0282). The rows are now <Vec<T>>::nil().
- In a program with goroutines, b.cells[y][x].Alive = true for a pointer b
wrote "*{ ... }[x]...". At the start of a statement Rust reads the block
as a statement of its own, and the line did not parse. The block is now
in parentheses.
Fixtures: grid_rows and grid_rows_goroutines run a small life board made
row by row, print rows of a [][]rune and a [][]byte with string(row), and
make a [][]T whose rows stay nil. Both match Go. 11 other snapshots
change, for the typed nil rows and the parentheses. Each was built and
run, and all match Go. The ratchet is unchanged;
TestNestedIndexThroughArrayOfSlicesUsesBareInnerSlice now expects the
parentheses.
Agent: claude-chat
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TkCXVghVg3khqYkpQSWyEM
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 52 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. |
|
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 1 day and 13 hours by commenting |
Reviewer's GuideImplementationTreat bare inner slices as slice values in string conversions and parenthesize block-valued inner slices before indexing, preventing incorrect borrowing and Rust parse errors.
Emit a typed nil value for each row when transpiling make([][]T, n), so the row element type is known.
ConfigurationAdd Cargo package manifests so the new grid fixtures can be built and run.
TestsAdd grid fixtures and regression checks for row string conversions, typed nil rows, and indexing block-valued rows, and register the fixtures.
Update the nested-index regression assertion to expect parentheses around a block-valued inner slice.
Refresh generated Rust snapshots affected by typed nil rows and parenthesized inner-slice expressions.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Fixes DEV-159.
Grid programs, such as game boards and matrices, hit three translator bugs:
for _, row := range board { fmt.Println(string(row)) }withboard [][]runestring(board[i])and for[][]bytegrid := make([][]Cell, h)when nothing else names the row typeVec::nil()with no element type<Vec<Cell>>::nil()b.cells[y][x].Alive = truefor a pointerb, in a program with goroutines*{ ... }[x]...at the start of a statement is a block followed by[x]The third one also hits ordinary programs, because
strings,bufioand the other packages translated from source make a program use the goroutine form.Fixtures:
grid_rowsandgrid_rows_goroutines. They run a small life board made row by row, print rows of a[][]runeand a[][]bytewithstring(row), and make a[][]Twhose rows stay nil. Both match Go. The board depends on #213 (make([]T, n)elements), which has landed.11 other snapshots change, for the typed nil rows and the parentheses. Each was built and run, and all match Go. The ratchet is unchanged.
TestNestedIndexThroughArrayOfSlicesUsesBareInnerSlicepinned the unparenthesized form and now expects the parentheses.— agent: claude-chat
Generated by Claude Code
Summary by Sourcery
Fix translation of nested slices and grid operations so generated programs compile and preserve Go behavior.
Bug Fixes:
Enhancements:
Tests: