Skip to content

Conversation

@forketyfork
Copy link
Owner

Replace .? with orelse return error.TestUnexpectedResult in tests that validate parsing functions return non-null for valid inputs.

This provides proper test failure messages instead of panics, and is more idiomatic Zig test code.

Replace `.?` with `orelse return error.TestUnexpectedResult` in tests
that validate parsing functions return non-null for valid inputs.

This provides proper test failure messages instead of panics, and is
more idiomatic Zig test code.
Replace `.?` force unwraps with `orelse return`/`orelse continue` patterns
for texture rendering and optional field access. This makes the code more
defensive and eliminates static analysis warnings about potentially unsafe
unwraps.

Changes:
- Render functions now unwrap textures with orelse return early
- Field access uses orelse continue in loops
- font_cache uses getOrPut to avoid put-then-getPtr pattern
- state.zig uses local variable instead of immediate unwrap after assignment
Reverts the defensive null check change since zwanzig now properly
recognizes the `if (x != null) { x.? }` pattern inside switch arms.

The original idiomatic Zig pattern is now correctly handled by the
linter without false positives.
Reverts the defensive null check change for the terminal access pattern
since zwanzig now properly recognizes `if (x != null) { x.? }` guards.

The line 310 case remains as defensive code since it relies on a labeled
block establishing an invariant that zwanzig can't track.
Zwanzig now handles the `self.method() catch return; ... self.field.?`
pattern via interprocedural analysis, so defensive code is no longer
needed.
Instead of having ensureTextures() set fields that are later unwrapped
in separate render functions, pass the textures as explicit parameters.
This makes the data flow clear and avoids fragile cross-function
assumptions about field state.

Also fix continue -> return false in session_interaction.zig where
there was no enclosing loop.
Zwanzig now handles `self.field = try expr; self.field.?` pattern.
Revert the defensive `orelse return false` to the original `.?` unwrap.
Zwanzig now correctly handles the labeled block invariant pattern where
`should_forward` being true implies `session.terminal` is non-null.
Update zwanzig dependency from v0.3.0 to v0.4.0
@forketyfork forketyfork merged commit 9c2e789 into main Feb 2, 2026
4 checks passed
@forketyfork forketyfork deleted the chore/bump-zwanzig-0.3.0 branch February 2, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants