-
-
Notifications
You must be signed in to change notification settings - Fork 1
[Zig 0.15.2 Compiler Bug] server.zig:503 - parser reports expected EOF found } #504
Copy link
Copy link
Open
Description
Minimal Reproduction
const std = @import("std");
const Allocator = std.mem.Allocator;
pub const Response = struct {
status: u16 = 200,
content_type: []const u8 = "application/json",
body: []const u8,
cors: bool = true,
};
pub fn errorName(err: anyerror) []const u8 {
return switch (err) {
error.ConnectionFailed => "ConnectionFailed",
error.InvalidResponse => "InvalidResponse",
error.AuthFailed => "AuthFailed",
error.GraphQL => "GraphQL",
else => "Unknown",
};
}
test "server: build health response" {
const response = Response{
.status = 200,
.content_type = "application/json",
.body = "{\"status\":\"ok\"}",
.cors = true,
};
try std.testing.expect(response.status == 200);
try std.testing.expectEqualStrings(response.body, "{\"status\":\"ok\"}");
}Steps to Reproduce
zig test /path/to/file.zig- Observe:
src/background_agent/server.zig:503:6: error: expected 'EOF', found '}'
Environment
- Zig version: 0.15.2 (Homebrew)
- OS: macOS Darwin 23.6.0
- Target: Debug native
Investigation Performed
- Hex dump shows no BOM or hidden characters
- Brace count: 149 open, 150 close (balanced)
- Test functions compile correctly in isolation
zig fmtproduces same error- Fixing railway/client.zig line 34 did NOT resolve this error
- Error persists even after removing errorName function entirely
Expected Behavior
The syntax }; at line 503 should correctly close the errorName() function. The compiler incorrectly reports it as an error.
This appears to be a compiler parser bug in Zig 0.15.2.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels