Skip to content

Replace removed ** array-repetition operator with @splat (fixes Zig master CI)#56

Merged
koko1123 merged 1 commit into
mainfrom
fix/zig-master-array-repeat
Jun 10, 2026
Merged

Replace removed ** array-repetition operator with @splat (fixes Zig master CI)#56
koko1123 merged 1 commit into
mainfrom
fix/zig-master-array-repeat

Conversation

@koko1123

@koko1123 koko1123 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What

Replaces all 360 uses of the ** array-repetition operator with @splat (and "prefix" ++ @as([N]u8, @splat(c)) for comptime hex/separator strings).

Why

Zig master (0.17.0-dev) removed the ** operator, so the Test / Zig master CI jobs fail on every file that uses it (the parser now lexes ** as two * tokens and reports "binary operator '*' has whitespace on one side, but not the other"). This was breaking CI on all open PRs.

How

  • [_]u8{X} ** N@as([N]u8, @splat(X)) (mechanical, 354 sites)
  • Annotated decls : [N]u8 = .{X} ** N= @splat(X)
  • Comptime strings "0x" ++ "00" ** 32"0x" ++ @as([64]u8, @splat('0')) (still coerces to []const u8 since the concat result is *const [N:0]u8)

@splat on arrays is supported since Zig 0.14, so the minimum supported version (0.15.2) is unaffected.

Verification

  • zig build test + zig fmt --check pass on 0.15.2 (make ci)
  • zig build test passes on 0.17.0-dev.813+2153f8143 (previously failed with 34 compile errors)

Note: zig build of the bench CLI and the examples still have separate 0.17-dev std-API breakages (std.process.args removal etc.) not exercised by CI; tracked under #55.

Refs #55

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Modernized internal array initialization patterns throughout the codebase to use more efficient Zig syntax conventions.

Zig master (0.17.0-dev) removed the ** array-multiplication operator,
breaking the Zig master CI job across 39 files. Replace all
single-element repeats with @Splat (supported since 0.14) and comptime
string repeats with "prefix" ++ @as([N]u8, @Splat(c)) concatenation.

Verified with zig build test on both 0.15.2 and 0.17.0-dev.813.

Refs #55
@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
eth-zig Ready Ready Preview, Comment Jun 10, 2026 1:02am

Request Review

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d8376cbe-caaf-4001-9511-9d794c7a2149

📥 Commits

Reviewing files that changed from the base of the PR and between 46f8dfc and 9472dd9.

📒 Files selected for processing (39)
  • bench/bench.zig
  • bench/keccak_compare.zig
  • bench/u256_bench.zig
  • src/abi_decode.zig
  • src/abi_encode.zig
  • src/access_list.zig
  • src/blob.zig
  • src/block.zig
  • src/contract.zig
  • src/eip712.zig
  • src/ens/namehash.zig
  • src/ens/reverse.zig
  • src/erc20.zig
  • src/erc721.zig
  • src/event.zig
  • src/flashbots.zig
  • src/hd_wallet.zig
  • src/hex.zig
  • src/keccak.zig
  • src/keccak_optimized.zig
  • src/mnemonic.zig
  • src/multicall.zig
  • src/primitives.zig
  • src/provider.zig
  • src/receipt.zig
  • src/rlp.zig
  • src/rpc_transaction.zig
  • src/secp256k1.zig
  • src/secp256k1_c.zig
  • src/signature.zig
  • src/signer.zig
  • src/state_overrides.zig
  • src/subscription.zig
  • src/transaction.zig
  • src/uint256.zig
  • src/wallet.zig
  • src/ws_client.zig
  • src/ws_transport.zig
  • tests/integration_tests.zig

📝 Walkthrough

Walkthrough

This PR systematically refactors fixed-size array initialization across 40+ files from Zig's [_]u8{value} ** N repetition syntax to the @as([N]u8, @Splat(value)) pattern. Changes include production constants (ZERO_ADDRESS, ZERO_HASH), internal buffer initialization in ABI encoding/EIP712 logic, and test fixtures throughout the codebase. No functional behavior changes.

Changes

Array initialization migration to @splat

Layer / File(s) Summary
Benchmarks and exported constants
bench/bench.zig, bench/keccak_compare.zig, bench/u256_bench.zig, src/primitives.zig
Benchmark test data and separator printing, plus exported ZERO_ADDRESS and ZERO_HASH constants, update to @splat initialization.
ABI encoding/decoding and EIP712
src/abi_encode.zig, src/abi_decode.zig, src/eip712.zig
ABI value defaults, internal encoding buffers, and test fixtures switch to @splat array construction for consistent 32-byte/20-byte initialization.
Cryptographic primitives and hashing
src/keccak.zig, src/keccak_optimized.zig, src/hex.zig, src/secp256k1.zig, src/secp256k1_c.zig, src/mnemonic.zig, src/signature.zig, src/signer.zig
Keccak state/padding buffers, RFC 6979 nonce generation, hex lookup table, and test vectors for cryptographic operations use @splat initialization.
Ethereum core data structures
src/block.zig, src/transaction.zig, src/access_list.zig, src/receipt.zig, src/rpc_transaction.zig, src/blob.zig
BlockHeader, Transaction, AccessListItem, TransactionReceipt, and BlobSidecar struct literals in tests update fixed-size byte fields to @splat.
Contract standards and service modules
src/erc20.zig, src/erc721.zig, src/contract.zig, src/multicall.zig, src/flashbots.zig, src/event.zig, src/state_overrides.zig
ERC20/ERC721 address initialization, contract address fixtures, multicall constants, bundle hashes, log topic/address arrays, and state override test data switch to @splat.
ENS and address utilities
src/ens/namehash.zig, src/ens/reverse.zig
ENS namehash zero-node initialization and reverse-resolver address construction update to @splat pattern.
Wallet and provider infrastructure
src/wallet.zig, src/provider.zig
Contract deployment zero-address, batch-caller test addresses, and block-header bloom/mixHash hex string construction update to @splat.
WebSocket transport and subscription
src/ws_client.zig, src/ws_transport.zig, src/subscription.zig, src/rlp.zig, src/uint256.zig
WebSocket message payloads, key generation, subscription topic/address arrays, RLP long-string fixtures, and uint256 test data switch to @splat initialization.
Integration tests
tests/integration_tests.zig
Genesis block hash, transaction hash, overridden-balance buffers, and storage-slot values update to @splat array construction.

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • StrobeLabs/eth.zig#24: Introduced the exact Keccak benchmark input constants and separator printing that this PR's benchmark refactoring updates, creating a direct code-level overlap in bench/keccak_compare.zig and bench/bench.zig.

🐰 Array splats cascade through,
@splat blooms where repetition grew—
Consistent, clean, and bright—
Fixed arrays done just right! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and concisely describes the main change: replacing the removed Zig ** array-repetition operator with @splat. This directly addresses the core issue affecting Zig master CI.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/zig-master-array-repeat

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

@koko1123
koko1123 merged commit 6b57f35 into main Jun 10, 2026
14 checks passed
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