Skip to content

Compile error when assigning and comparing to ??u8 #24935

@uyha

Description

@uyha

Zig Version

0.15.1

Steps to Reproduce and Observed Behavior

compile the following snippet

pub fn main() !void {
    var value: ??u8 = null;

    value = 1;
    std.debug.print("{}\n", .{value == 1});
}

const std = @import("std");

and the compiler fails with

error: failed to select cmp_eq ??u8 |(none)| dx |(none)| si
pub fn main() !void {
~~~~^~~~~~~~~~~~~~~

It doesn't fail with

pub fn main() !void {
    const value: ??u8 = 1;

    std.debug.print("{}\n", .{value == 1});
}

const std = @import("std");

Expected Behavior

The snippet should be compiled fine and prints out true

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-x86_6464-bit x86backend-self-hostedbugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions