Skip to content

fix(antd-zig): align stdlib API usage with Zig 0.14.x (the declared minimum)#82

Open
Nic-dorman wants to merge 1 commit into
mainfrom
fix/zig-014-stdlib-api
Open

fix(antd-zig): align stdlib API usage with Zig 0.14.x (the declared minimum)#82
Nic-dorman wants to merge 1 commit into
mainfrom
fix/zig-014-stdlib-api

Conversation

@Nic-dorman
Copy link
Copy Markdown
Collaborator

Fixes #78.

What was wrong

antd-zig didn't compile on any released Zig because the source mixed APIs from different versions:

File 0.15-dev only 0.14.x only
json_helpers.zig std.ArrayList(u8) = .empty initializer + .append(allocator, x) / .appendSlice(allocator, x) / .deinit(allocator) / .writer(allocator) / .toOwnedSlice(allocator)
antd.zig req.status shortcut on http.Client.Request client.open(method, uri, ...)

So:

  • On Zig 0.14.1: .empty initializer fails (struct array_list.ArrayListAligned(u8,null) has no member named empty).
  • On Zig 0.15.2: client.open is gone (http.Client has no member 'open').

build.zig.zon declares minimum_zig_version = "0.14.0", so this PR aligns everything to 0.14.x.

Changes

  • json_helpers.zig.empty initializer → .init(allocator); allocator-on-call (.append(allocator, x) etc.) → allocator-on-init (.append(x)).
  • antd.zig@intFromEnum(req.status)@intFromEnum(req.response.status) (response struct lives one level deeper in 0.14).
  • tests.zig — the parseCost test referenced a helper that no longer exists; renamed/updated to use parseCostEstimate with a full estimate-shaped JSON body and assert result.cost.

Verification (Zig 0.14.1)

$ zig version
0.14.1
$ zig build              # clean
$ zig build test         # all tests pass
$ zig build run-01-connect
Connected to antd daemon
  OK: true
  Network: local
$ zig build run-03-chunks
Storing chunk...
Chunk stored at: 6ab645b00a274906075279f26ff3bdb4f20b98248f33e9ee7d642c29b0a6c19f
…

What this PR does not fix

  • examples/02-data.zig and examples/06-private-data.zig still need the arity fix from antd-zig: example 02-data calls dataPutPublic(message) but API requires (data, payment_mode) #70 / #79 before they can run end-to-end. With both PRs applied the harness runs them green.
  • examples/04-files.zig runtime-errors when /tmp/example.txt is absent — that's a test-data setup concern in the example, not a compile concern.
  • examples/05-graph.zig calls graphEntryPut/Get/Exists/Cost on Client, none of which exist in src/antd.zig. The entire graph example targets an API surface that hasn't landed — worth a separate ticket.

…inimum)

The source mixed APIs from different Zig versions and did not compile on
any released Zig (see #78):

- json_helpers.zig used 0.15-dev ArrayList style:
    var list: std.ArrayList(u8) = .empty;
    list.append(allocator, c);
    list.deinit(allocator);
    list.toOwnedSlice(allocator);

  These are not present in Zig 0.14.x, which is what build.zig.zon
  declares as minimum_zig_version. Switch to the 0.14 style:
    var list = std.ArrayList(u8).init(allocator);
    list.append(c);
    list.deinit();
    list.toOwnedSlice();

- antd.zig used req.status which is a 0.15-dev shortcut. In 0.14.x the
  response struct sits one level deeper:
    @intFromEnum(req.status)         -> @intFromEnum(req.response.status)

- tests.zig referenced a json_helpers.parseCost helper that no longer
  exists. Rename the test to use parseCostEstimate (the actual helper)
  and adjust the expected JSON body + assertion.

After this change:
  $ zig version
  0.14.1
  $ zig build           # builds clean
  $ zig build test      # all unit tests pass
  $ zig build run-01-connect  # connects to a live antd daemon
  $ zig build run-03-chunks   # stores a chunk on the local devnet

Examples 02 + 06 still need the arity fix tracked in #70 (PR #79) before
they can run end-to-end; 04-files fails at runtime when /tmp/example.txt
is absent (test data, not a compile concern); 05-graph references SDK
methods (graphEntryPut/Get/Exists/Cost) that do not exist in src/antd.zig
- a separate issue worth filing.

Closes #78
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.

antd-zig source uses Zig APIs from incompatible versions; doesn't compile on any released Zig

1 participant