I’m running into an odd comptime issue when I was trying some sample code using evented + Grand Central Dispatch, and I’m not quite understanding it. I suspect this is just a standard library bug but I’m still not positive that it isn’t user error. The issue happens for me on both master (0.17.0-dev.1275+59a628c6d) and 0.16.0.
A minimal failing example (adapted from here, which also fails if copied verbatim):
In particular the assertion that you’re tripping should not exist on master anymore; could you try updating Zig and seeing if your minimal program still fails to compile?
Ah, good catch—I somehow didn’t notice that building with master resulting in a different (albeit similar) error message. Here’s what the compile log looks like on master (0.17.0-dev.1282+c0f9b51d8):
❯ zig build
install
└─ install newzidk
└─ compile exe newzidk Debug native 1 errors
/Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/lib/std/debug.zig:435:14: error: reached unreachable code
if (!ok) unreachable; // assertion failure
^~~~~~~~~~~
/Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/lib/std/mem.zig:4711:11: note: called at comptime here
assert(info.size == .slice);
~~~~~~^~~~~~~~~~~~~~~~~~~~~
/Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/lib/std/mem.zig:4718:63: note: called at comptime here
pub fn absorbSentinel(slice: anytype) AbsorbSentinelReturnType(@TypeOf(slice)) {
~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/lib/std/mem/Allocator.zig:452:63: note: generic function instantiated here
const bytes: []u8 = @ptrCast(@constCast(mem.absorbSentinel(memory)));
~~~~~~~~~~~~~~~~~~^~~~~~~~
referenced by:
deinit: /Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/lib/std/Io/Dispatch.zig:583:30
main: src/main.zig:11:25
4 reference(s) hidden; use '-freference-trace=6' to see all references
error: 1 compilation errors
failed command: /Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/zig build-exe -ODebug --dep newzidk -Mroot=src/main.zig -Mnewzidk=src/root.zig --cache-dir .zig-cache --global-cache-dir /Users/perry/.cache/zig --name newzidk --zig-lib-dir /Users/perry/.cache/zig/p/N-V-__8AAMlw-BajASJzv2qM-Wcf7ijzIYrCy_OFSd6KO2-Z/lib/ --listen=-
Build Summary: 0/3 steps succeeded (1 failed)
install transitive failure
└─ install newzidk transitive failure
└─ compile exe newzidk Debug native 1 errors