Skip to content

[Zig 0.15.2 Compiler Bug] server.zig:503 - parser reports expected EOF found } #504

@gHashTag

Description

@gHashTag

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

  1. zig test /path/to/file.zig
  2. 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 fmt produces 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions