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
Open
fix(antd-zig): align stdlib API usage with Zig 0.14.x (the declared minimum)#82Nic-dorman wants to merge 1 commit into
Nic-dorman wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #78.
What was wrong
antd-zigdidn't compile on any released Zig because the source mixed APIs from different versions:json_helpers.zigstd.ArrayList(u8) = .emptyinitializer +.append(allocator, x)/.appendSlice(allocator, x)/.deinit(allocator)/.writer(allocator)/.toOwnedSlice(allocator)antd.zigreq.statusshortcut onhttp.Client.Requestclient.open(method, uri, ...)So:
.emptyinitializer fails (struct array_list.ArrayListAligned(u8,null) has no member named empty).client.openis gone (http.Client has no member 'open').build.zig.zondeclaresminimum_zig_version = "0.14.0", so this PR aligns everything to 0.14.x.Changes
json_helpers.zig—.emptyinitializer →.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— theparseCosttest referenced a helper that no longer exists; renamed/updated to useparseCostEstimatewith a full estimate-shaped JSON body and assertresult.cost.Verification (Zig 0.14.1)
What this PR does not fix
examples/02-data.zigandexamples/06-private-data.zigstill need the arity fix from antd-zig: example 02-data callsdataPutPublic(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.zigruntime-errors when/tmp/example.txtis absent — that's a test-data setup concern in the example, not a compile concern.examples/05-graph.zigcallsgraphEntryPut/Get/Exists/CostonClient, none of which exist insrc/antd.zig. The entire graph example targets an API surface that hasn't landed — worth a separate ticket.