Skip to content

Use syntax that builds on both Zig 0.16 and 0.17 - #790

Merged
lalinsky merged 1 commit into
mainfrom
zig-0.17-prep
Oct 5, 2026
Merged

lalinsky merged 1 commit into
mainfrom
zig-0.17-prep

Conversation

@lalinsky

@lalinsky lalinsky commented Oct 5, 2026

Copy link
Copy Markdown
Owner

First step of making the zig-0.17 port minimal: backport everything from it that is also valid on Zig 0.16.

  • The ** array repetition operator is gone in 0.17; use @splat or an explicit literal instead.
  • std.meta.Tuple is gone in 0.17; @Tuple exists in both.
  • std.os.linux.getdents64 takes a c_uint length in 0.17; clamp and cast.
  • The Windows sockaddr no longer @bitCasts from sockaddr.in in 0.17; pass the concrete type through a pointer cast.

Next step is a small compat.zig for the things that need a version check (optimize mode tags, struct field/error set reflection), after which the zig-0.17 branch gets rebased onto main.

Backport the parts of the zig-0.17 port that are valid on 0.16 too, so the
port branch only carries what really differs between the versions:

- The `**` array repetition operator is gone in 0.17; use `@splat` or an
  explicit literal instead.
- `std.meta.Tuple` is gone in 0.17; `@Tuple` exists in both.
- `std.os.linux.getdents64` takes a `c_uint` length in 0.17; clamp and cast.
- The Windows `sockaddr` no longer `@bitCast`s from `sockaddr.in` in 0.17;
  pass the concrete type through a pointer cast.
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: lalinsky/zio/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d44c687b-8c69-4819-a93c-91d56dd9ae02
📥 Commits

Reviewing files that changed from the base of the PR and between dd5bc84 and c84f97e.

📒 Files selected for processing (11)
  • src/coro/coroutines.zig
  • src/dns/resolver/resolver.zig
  • src/ev/sockreg.zig
  • src/fs.zig
  • src/group.zig
  • src/net.zig
  • src/os/fs.zig
  • src/os/net.zig
  • src/runtime.zig
  • src/select.zig
  • test_runner.zig

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Array and tuple initializers changed across several modules and tests. Linux directory reading now caps the length passed to getdents64, and loopback socket setup passes a typed IPv4 address to bind.

Changes

Zig and OS updates

Layer / File(s) Summary
Array and tuple construction updates
src/coro/coroutines.zig, src/dns/resolver/resolver.zig, src/ev/sockreg.zig, src/fs.zig, src/group.zig, src/net.zig, src/os/fs.zig, src/runtime.zig, src/select.zig, test_runner.zig
Array and tuple initialization changes use @Tuple, @splat, or explicit array values. Existing address values, test expectations, and buffer contents remain unchanged.
POSIX syscall and address handling
src/os/fs.zig, src/os/net.zig
Linux directory reading caps the buffer length at maxInt(c_uint) before calling getdents64. Loopback socket setup passes a typed IPv4 address to bind instead of a bitcast generic address.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to c84f9

The changes preserve the described initializer values and the inspected filesystem and socket behavior. No concrete merge-blocking issue is established; compatibility with Zig 0.17 remains unverified.

Architecture Summary

Architecture risk: 🔵 Low · up to c84f9

The change affects 2 systems.

Changed systems: src, test_runner.zig

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 10 changed files map to changed impact.
  • observed — test_runner.zig (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/coro/coroutines.zig: Closure now uses the @Tuple builtin to construct UserArgs instead of std.meta.Tuple.
  • observed — Modified behavior in src/dns/resolver/resolver.zig: The localhost IPv6 loopback initializer now lists its 15 zero bytes and final 1 explicitly; the previous repeated-zero array expression was removed.
  • observed — Modified behavior in src/ev/sockreg.zig: Table.shards now initializes its array with @splat(.{}) instead of the repeated-struct array expression.
  • observed — Modified behavior in src/fs.zig: The test replaces the repeated-string prefix with a fixed-size byte array filled with x, passing its slice to both creation calls while retaining the NameTooLong expectations.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: using syntax compatible with Zig 0.16 and 0.17.
Description check ✅ Passed The description explains the compatibility changes in the pull request and identifies the planned follow-up work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Zeroes settle into place
Tuple shapes take a new form
Loopback binds its typed address
Directory reads meet their limit
Tests keep their expected marks

Comment @coderabbitai help to get the list of available commands.

@lalinsky
lalinsky merged commit 4aaa109 into main Oct 5, 2026
36 checks passed
@lalinsky
lalinsky deleted the zig-0.17-prep branch October 5, 2026 11:37
lalinsky added a commit that referenced this pull request Oct 5, 2026
Rebased from the zig-0.17 branch onto main, which by now carries everything
from the port that also builds on 0.16 (#790, #791). What is left is what
can only be written one way per version:

- `netSend`, `netRead` and `netWrite` left `Io.VTable` and became the
  `net_send`, `net_read` and `net_write` operations, served by both the
  single-operation and the batch paths. They take the clock along with the
  timeout, like the other operations on main.
- `processSpawnPath`/`processReplacePath` are gone from the vtable, replaced
  by `inheritParentDir`/`inheritParentFile`; the two tests for the old
  entry points go with them.
- `ip6_only` is `?bool`; null leaves the socket option alone.
- `Io.net.UnixAddress.ConnectError` has `ConnectionRefused`, so a refused
  unix connect is reported as such instead of `error.Unexpected`.
- The `AccessDenied` mapping for bind/listen is still blocked upstream, so
  those markers no longer name the port.
- `std.testing.allocator_instance` is a `SafeAllocator` initialized with its
  backing allocator, and `deinit` returns the leak count.
lalinsky added a commit that referenced this pull request Oct 5, 2026
Rebased from the zig-0.17 branch onto main, which by now carries everything
from the port that also builds on 0.16 (#790, #791). What is left is what
can only be written one way per version:

- `netSend`, `netRead` and `netWrite` left `Io.VTable` and became the
  `net_send`, `net_read` and `net_write` operations, served by both the
  single-operation and the batch paths. They take the clock along with the
  timeout, like the other operations on main.
- `processSpawnPath`/`processReplacePath` are gone from the vtable, replaced
  by `inheritParentDir`/`inheritParentFile`; the two tests for the old
  entry points go with them.
- `ip6_only` is `?bool`; null leaves the socket option alone.
- `Io.net.UnixAddress.ConnectError` has `ConnectionRefused`, so a refused
  unix connect is reported as such instead of `error.Unexpected`.
- The `AccessDenied` mapping for bind/listen is still blocked upstream, so
  those markers no longer name the port.
- `std.testing.allocator_instance` is a `SafeAllocator` initialized with its
  backing allocator, and `deinit` returns the leak count.
lalinsky added a commit that referenced this pull request Oct 5, 2026
* Port the std.Io implementation to Zig 0.17

Rebased from the zig-0.17 branch onto main, which by now carries everything
from the port that also builds on 0.16 (#790, #791). What is left is what
can only be written one way per version:

- `netSend`, `netRead` and `netWrite` left `Io.VTable` and became the
  `net_send`, `net_read` and `net_write` operations, served by both the
  single-operation and the batch paths. They take the clock along with the
  timeout, like the other operations on main.
- `processSpawnPath`/`processReplacePath` are gone from the vtable, replaced
  by `inheritParentDir`/`inheritParentFile`; the two tests for the old
  entry points go with them.
- `ip6_only` is `?bool`; null leaves the socket option alone.
- `Io.net.UnixAddress.ConnectError` has `ConnectionRefused`, so a refused
  unix connect is reported as such instead of `error.Unexpected`.
- The `AccessDenied` mapping for bind/listen is still blocked upstream, so
  those markers no longer name the port.
- `std.testing.allocator_instance` is a `SafeAllocator` initialized with its
  backing allocator, and `deinit` returns the leak count.

* Apply zig fmt from Zig 0.17

The 0.17 formatter rewrites the deprecated @intFromEnum/@enumFromInt to
@backingInt/@fromBackingInt. Neither exists in 0.16, so this is the one
mechanical change that has to stay on the 0.17 side; rerun zig fmt to
regenerate it.

* Switch CI, docs and minimum version to Zig 0.17

* Point Zig 0.16 users to the zig-0.16 branch

* Note the Zig 0.17 requirement in the changelog

---------

Co-authored-by: Jan Beelte <jan@beeltek.eu>
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.

1 participant