zig/test/cases/compile_errors/minmax_nonnumeric_operand.zig
Alex Rønne Petersen 2e3fac3626
test: rename backend=stage2 to backend=selfhosted, and add backend=auto
backend=auto (now the default if backend is omitted) means to let the compiler
pick whatever backend it wants as the default. This is important for platforms
where we don't yet have a self-hosted backend, such as loongarch64.

Also purge a bunch of redundant target=native.
2025-09-16 23:39:26 +02:00

39 lines
1.6 KiB
Zig

// zig fmt: off
comptime { _ = @min(0, u32); } // type
comptime { _ = @max(0, {}); } // void
comptime { _ = @min(0, false); } // boolean
comptime { _ = @min(0, &@as(u8, 0)); } // pointer
comptime { _ = @max(0, [0]u8{}); } // array
comptime { _ = @min(0, Struct{}); } // struct
comptime { _ = @max(0, null); } // null
comptime { _ = @min(0, @as(?u8, 0)); } // nullable
comptime { _ = @max(0, @as(error{}!u8, 0)); } // error union
comptime { _ = @min(0, error.Foo); } // error set
comptime { _ = @max(0, Enum.foo); } // enum
comptime { _ = @min(0, Union{ .foo = {} }); } // union
comptime { _ = @max(0, struct { fn func() u8 { return 42; }}.func); }
comptime { _ = @max(0, .foo); } // enum literal
const Struct = struct {};
const Enum = enum { foo };
const Union = union { foo: void };
// error
//
// :2:24: error: expected number, found 'type'
// :3:24: error: expected number, found 'void'
// :4:24: error: expected number, found 'bool'
// :5:24: error: expected number, found '*const u8'
// :6:29: error: expected number, found '[0]u8'
// :7:30: error: expected number, found 'tmp.Struct'
// :17:16: note: struct declared here
// :8:24: error: expected number, found '@TypeOf(null)'
// :9:24: error: expected number, found '?u8'
// :10:24: error: expected number, found 'error{}!u8'
// :11:24: error: expected number, found 'error{Foo}'
// :12:28: error: expected number, found 'tmp.Enum'
// :18:14: note: enum declared here
// :13:29: error: expected number, found 'tmp.Union'
// :19:15: note: union declared here
// :14:61: error: expected number, found 'fn () u8'
// :15:25: error: expected number, found '@Type(.enum_literal)'