Skip to content

ability to use == to compare nullable pointers #1226

@andrewrk

Description

@andrewrk
test "aoeu" {
    var x: ?*i32 = undefined;
    var y: ?*i32 = undefined;
    var z = x == y;
}
/home/andy/downloads/zig/build/test.zig:4:15: error: operator not allowed for type '?*i32'
    var z = x == y;
              ^

nullable pointers are guaranteed to be codegen as a normal pointer with the 0 value for null. So this should work. It should work with these combinations:

  • ?*T and ?*T
  • *T and ?*T
  • ?*T and *T

It should also work with ?promise and ?fn() since these are also guaranteed to be pointers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions