Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: Invalid record (Producer: 'zig 0.13.0' Reader: 'LLVM 18.1.8') #22703

Open
gfokkema opened this issue Jan 31, 2025 · 1 comment
Open

error: Invalid record (Producer: 'zig 0.13.0' Reader: 'LLVM 18.1.8') #22703

gfokkema opened this issue Jan 31, 2025 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@gfokkema
Copy link

Zig Version

zig 0.13.0

Steps to Reproduce and Observed Behavior

const std = @import("std");

pub fn main() !void {
    std.debug.print("Test\n", .{});
    var line = "Hello world";
    const head: *const [3]u8 = line[0..3];
    try switch (head) {
        &[3]u8{'H', 'e', 'l'} => std.debug.print("Match!\n", .{}),
	else => error.hi,
    };
}

Compiling and running above yields:
$ zig run test.zig
error: Invalid record (Producer: 'zig 0.13.0' Reader: 'LLVM 18.1.8')

Expected Behavior

Since officially zig doesn't support switching on strings, I'd expect a compiler error instead of invalid LLVM bytecode.

@gfokkema gfokkema added the bug Observed behavior contradicts documented or intended behavior label Jan 31, 2025
@rohlem
Copy link
Contributor

rohlem commented Feb 1, 2025

Since officially zig doesn't support switching on strings

Technically your example is switching on a pointer (= an address), not its pointed-to array elements.
While this isn't used often, I do think it is intended to be supported (so I think your example is correct and it not compiling is indeed a bug).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

2 participants