Merge pull request #21961 from mlugg/incr-cases

incremental: remove legacy cases, add some new ones
This commit is contained in:
Matthew Lugg 2024-11-11 20:00:00 +00:00 committed by GitHub
commit 28bdab385a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
182 changed files with 192 additions and 2456 deletions

View File

@ -1,10 +0,0 @@
pub fn main() void {
add(3, 4);
}
fn add(a: u32, b: u32) void {
if (a + b != 7) unreachable;
}
// run
//

View File

@ -1,12 +0,0 @@
pub fn main() void {
if (x - 7 != 0) unreachable;
}
fn add(a: u32, b: u32) u32 {
return a + b;
}
const x = add(3, 4);
// run
//

View File

@ -1,13 +0,0 @@
pub fn main() void {
var x: usize = 3;
_ = &x;
const y = add(1, 2, x);
if (y - 6 != 0) unreachable;
}
inline fn add(a: usize, b: usize, c: usize) usize {
return a + b + c;
}
// run
//

View File

@ -1,17 +0,0 @@
const std = @import("std");
pub fn main() void {
print(2, 4);
print(1, 7);
}
fn print(a: u32, b: u32) void {
const str = "123456789";
const len = a + b;
_ = std.posix.write(1, str[0..len]) catch {};
}
// run
// target=x86_64-linux,x86_64-macos
//
// 12345612345678

View File

@ -1,16 +0,0 @@
const std = @import("std");
pub fn main() void {
print(10, 5);
print(4, 3);
}
fn print(a: u32, b: u32) void {
const str = "123456789";
const len = a - b;
_ = std.posix.write(1, str[0..len]) catch {};
}
// run
//
// 123451

View File

@ -1,16 +0,0 @@
const std = @import("std");
pub fn main() void {
print(8, 9);
print(3, 7);
}
fn print(a: u32, b: u32) void {
const str = "123456789";
const len = a & b;
_ = std.posix.write(1, str[0..len]) catch {};
}
// run
//
// 12345678123

View File

@ -1,16 +0,0 @@
const std = @import("std");
pub fn main() void {
print(4, 2);
print(3, 7);
}
fn print(a: u32, b: u32) void {
const str = "123456789";
const len = a | b;
_ = std.posix.write(1, str[0..len]) catch {};
}
// run
//
// 1234561234567

View File

@ -1,16 +0,0 @@
const std = @import("std");
pub fn main() void {
print(42, 42);
print(3, 5);
}
fn print(a: u32, b: u32) void {
const str = "123456789";
const len = a ^ b;
_ = std.posix.write(1, str[0..len]) catch {};
}
// run
//
// 123456

View File

@ -1,15 +0,0 @@
pub fn main() void {
var x: u32 = 1;
assert(x << 1 == 2);
x <<= 1;
assert(x << 2 == 8);
assert(x << 3 == 16);
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,21 +0,0 @@
pub fn main() void {
var a: u32 = 1024;
assert(a >> 1 == 512);
a >>= 1;
assert(a >> 2 == 128);
assert(a >> 3 == 64);
assert(a >> 4 == 32);
assert(a >> 5 == 16);
assert(a >> 6 == 8);
assert(a >> 7 == 4);
assert(a >> 8 == 2);
assert(a >> 9 == 1);
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,15 +0,0 @@
pub fn main() void {
add(3, 4);
}
fn add(a: u32, b: u32) void {
assert(a + b == 7);
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
// target=x86_64-macos,x86_64-linux
// link_libc=true

View File

@ -1,17 +0,0 @@
pub fn main() void {
add(3, 4);
}
fn add(a: u32, b: u32) void {
const c = a + b; // 7
const d = a + c; // 10
const e = d + b; // 14
assert(e == 14);
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,27 +0,0 @@
pub fn main() void {
assert(add(3, 4) == 116);
}
fn add(a: u32, b: u32) u32 {
const x: u32 = blk: {
const c = a + b; // 7
const d = a + c; // 10
const e = d + b; // 14
const f = d + e; // 24
const g = e + f; // 38
const h = f + g; // 62
const i = g + h; // 100
const j = i + d; // 110
break :blk j;
};
const y = x + a; // 113
const z = y + a; // 116
return z;
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,66 +0,0 @@
pub fn main() void {
assert(add(3, 4) == 1221);
assert(mul(3, 4) == 21609);
}
fn add(a: u32, b: u32) u32 {
const x: u32 = blk: {
const c = a + b; // 7
const d = a + c; // 10
const e = d + b; // 14
const f = d + e; // 24
const g = e + f; // 38
const h = f + g; // 62
const i = g + h; // 100
const j = i + d; // 110
const k = i + j; // 210
const l = j + k; // 320
const m = l + c; // 327
const n = m + d; // 337
const o = n + e; // 351
const p = o + f; // 375
const q = p + g; // 413
const r = q + h; // 475
const s = r + i; // 575
const t = s + j; // 685
const u = t + k; // 895
const v = u + l; // 1215
break :blk v;
};
const y = x + a; // 1218
const z = y + a; // 1221
return z;
}
fn mul(a: u32, b: u32) u32 {
const x: u32 = blk: {
const c = a * a * a * a; // 81
const d = a * a * a * b; // 108
const e = a * a * b * a; // 108
const f = a * a * b * b; // 144
const g = a * b * a * a; // 108
const h = a * b * a * b; // 144
const i = a * b * b * a; // 144
const j = a * b * b * b; // 192
const k = b * a * a * a; // 108
const l = b * a * a * b; // 144
const m = b * a * b * a; // 144
const n = b * a * b * b; // 192
const o = b * b * a * a; // 144
const p = b * b * a * b; // 192
const q = b * b * b * a; // 192
const r = b * b * b * b; // 256
const s = c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r; // 2401
break :blk s;
};
const y = x * a; // 7203
const z = y * a; // 21609
return z;
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,47 +0,0 @@
pub fn main() void {
assert(add(3, 4) == 791);
assert(add(4, 3) == 79);
}
fn add(a: u32, b: u32) u32 {
const x: u32 = if (a < b) blk: {
const c = a + b; // 7
const d = a + c; // 10
const e = d + b; // 14
const f = d + e; // 24
const g = e + f; // 38
const h = f + g; // 62
const i = g + h; // 100
const j = i + d; // 110
const k = i + j; // 210
const l = k + c; // 217
const m = l + d; // 227
const n = m + e; // 241
const o = n + f; // 265
const p = o + g; // 303
const q = p + h; // 365
const r = q + i; // 465
const s = r + j; // 575
const t = s + k; // 785
break :blk t;
} else blk: {
const t = b + b + a; // 10
const c = a + t; // 14
const d = c + t; // 24
const e = d + t; // 34
const f = e + t; // 44
const g = f + t; // 54
const h = c + g; // 68
break :blk h + b; // 71
};
const y = x + a; // 788, 75
const z = y + a; // 791, 79
return z;
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,19 +0,0 @@
pub fn main() void {
const ignore =
\\ cool thx
\\
;
_ = ignore;
add('ぁ', '\x03');
}
fn add(a: u32, b: u32) void {
assert(a + b == 12356);
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,17 +0,0 @@
pub fn main() void {
add(aa, bb);
}
const aa = 'ぁ';
const bb = '\x03';
fn add(a: u32, b: u32) void {
assert(a + b == 12356);
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,10 +0,0 @@
pub fn main() void {
assert("hello"[0] == 'h');
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,11 +0,0 @@
const hello = "hello".*;
pub fn main() void {
assert(hello[1] == 'e');
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,12 +0,0 @@
pub fn main() void {
var i: u64 = 0xFFEEDDCCBBAA9988;
_ = &i;
assert(i == 0xFFEEDDCCBBAA9988);
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,20 +0,0 @@
const builtin = @import("builtin");
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
for ("hello") |_| print();
}
fn print() void {
_ = write(1, @intFromPtr("hello\n"), 6);
}
// run
//
// hello
// hello
// hello
// hello
// hello
//

View File

@ -1,21 +0,0 @@
pub fn main() void {
add(3, 4);
}
fn add(a: u32, b: u32) void {
const c = a + b; // 7
const d = a + c; // 10
const e = d + b; // 14
const f = d + e; // 24
const g = e + f; // 38
const h = f + g; // 62
const i = g + h; // 100
assert(i == 100);
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,22 +0,0 @@
pub fn main() void {
add(3, 4);
}
fn add(a: u32, b: u32) void {
const c = a + b; // 7
const d = a + c; // 10
const e = d + b; // 14
const f = d + e; // 24
const g = e + f; // 38
const h = f + g; // 62
const i = g + h; // 100
const j = i + d; // 110
assert(j == 110);
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,15 +0,0 @@
pub fn main() void {
assert(add(3, 4) == 7);
assert(add(20, 10) == 30);
}
fn add(a: u32, b: u32) u32 {
return a + b;
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,19 +0,0 @@
pub fn main() void {
assert(add(3, 4) == 7);
assert(add(20, 10) == 30);
}
fn add(a: u32, b: u32) u32 {
var x: u32 = undefined;
x = 0;
x += a;
x += b;
return x;
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
const a: u32 = 2;
const b: ?u32 = a;
const c = b.?;
if (c != 2) unreachable;
}
// run
//

View File

@ -1,23 +0,0 @@
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
var i: u32 = 0;
while (i < 4) : (i += 1) print();
assert(i == 4);
}
fn print() void {
_ = write(1, @intFromPtr("hello\n"), 6);
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//
// hello
// hello
// hello
// hello
//

View File

@ -1,20 +0,0 @@
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
var i: u32 = 0;
inline while (i < 4) : (i += 1) print();
assert(i == 4);
}
fn print() void {
_ = write(1, @intFromPtr("hello\n"), 6);
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// error
//
// :5:21: error: unable to resolve comptime value
// :5:21: note: condition in comptime branch must be comptime-known

View File

@ -1,22 +0,0 @@
pub fn main() void {
assert(add(3, 4) == 20);
}
fn add(a: u32, b: u32) u32 {
const x: u32 = blk: {
const c = a + b; // 7
const d = a + c; // 10
const e = d + b; // 14
break :blk e;
};
const y = x + a; // 17
const z = y + a; // 20
return z;
}
pub fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var i: u8 = 5;
i += 20;
if (i != 25) unreachable;
}
// run
// target=wasm32-wasi
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var i: i32 = 2147483647;
_ = &i;
if (i +% 1 != -2147483648) unreachable;
return;
}
// run
//

View File

@ -1,14 +0,0 @@
pub fn main() void {
var i: u32 = 5;
i *= 7;
var result: u32 = foo(i, 10);
_ = &result;
if (result != 350) unreachable;
return;
}
fn foo(x: u32, y: u32) u32 {
return x * y;
}
// run
//

View File

@ -1,10 +0,0 @@
pub fn main() void {
var i: i32 = 2147483647;
_ = &i;
const result = i *% 2;
if (result != -2) unreachable;
return;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var i: u3 = 3;
_ = &i;
if (i *% 3 != 1) unreachable;
return;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var i: i4 = 3;
_ = &i;
if (i *% 3 != -7) unreachable;
return;
}
// run
//

View File

@ -1,13 +0,0 @@
pub fn main() void {
var i: u32 = 352;
i /= 7; // i = 50
const result: u32 = foo(i, 7);
if (result != 7) unreachable;
return;
}
fn foo(x: u32, y: u32) u32 {
return x / y;
}
// run
//

View File

@ -1,8 +0,0 @@
pub fn main() u8 {
var i: u8 = 5;
i &= 6;
return i - 4;
}
// run
//

View File

@ -1,8 +0,0 @@
pub fn main() u8 {
var i: u8 = 5;
i |= 6;
return i - 7;
}
// run
//

View File

@ -1,8 +0,0 @@
pub fn main() u8 {
var i: u8 = 5;
i ^= 6;
return i - 3;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = false;
b = b or false;
if (b) unreachable;
return;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = true;
b = b or false;
if (!b) unreachable;
return;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var i: i4 = 7;
_ = &i;
if (i +% 1 != -8) unreachable;
return;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = false;
b = b or true;
if (!b) unreachable;
return;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = true;
b = b or true;
if (!b) unreachable;
return;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = false;
b = b and false;
if (b) unreachable;
return;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = true;
b = b and false;
if (b) unreachable;
return;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = false;
b = b and true;
if (b) unreachable;
return;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var b: bool = true;
b = b and true;
if (!b) unreachable;
return;
}
// run
//

View File

@ -1,8 +0,0 @@
pub fn main() u8 {
var i: u8 = 255;
_ = &i;
return i +% 1;
}
// run
//

View File

@ -1,12 +0,0 @@
pub fn main() u8 {
var i: u8 = 5;
i += 20;
const result: u8 = foo(i, 10);
return result - 35;
}
fn foo(x: u8, y: u8) u8 {
return x + y;
}
// run
//

View File

@ -1,8 +0,0 @@
pub fn main() u8 {
var i: u8 = 20;
i -= 5;
return i - 15;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var i: i32 = -2147483648;
_ = &i;
if (i -% 1 != 2147483647) unreachable;
return;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
var i: i7 = -64;
_ = &i;
if (i -% 1 != 63) unreachable;
return;
}
// run
//

View File

@ -1,8 +0,0 @@
pub fn main() void {
var i: u4 = 0;
_ = &i;
if (i -% 1 != 15) unreachable;
}
// run
//

View File

@ -1,13 +0,0 @@
pub fn main() u8 {
var i: u8 = 5;
i -= 3;
var result: u8 = foo(i, 10);
_ = &result;
return result - 8;
}
fn foo(x: u8, y: u8) u8 {
return y - x;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() void {
while (true) {
break;
}
}
// run
// target=x86_64-linux,x86_64-macos
//

View File

@ -1,8 +0,0 @@
pub fn main() void {
foo: while (true) {
break :foo;
}
}
// run
//

View File

@ -1,10 +0,0 @@
pub fn main() void {
var i: u64 = 0;
while (true) : (i += 1) {
if (i == 4) return;
continue;
}
}
// run
//

View File

@ -1,10 +0,0 @@
pub fn main() void {
var i: u64 = 0;
foo: while (true) : (i += 1) {
if (i == 4) return;
continue :foo;
}
}
// run
//

View File

@ -1,11 +0,0 @@
pub fn main() void {
const i: anyerror!u64 = 0;
const caught = i catch 5;
assert(caught == 0);
}
fn assert(b: bool) void {
if (!b) unreachable;
}
// run
//

View File

@ -1,11 +0,0 @@
pub fn main() void {
const i: anyerror!u64 = error.B;
const caught = i catch 5;
assert(caught == 5);
}
fn assert(b: bool) void {
if (!b) unreachable;
}
// run
//

View File

@ -1,11 +0,0 @@
pub fn main() void {
const a: anyerror!comptime_int = 42;
const b: *const comptime_int = &(a catch unreachable);
assert(b.* == 42);
}
fn assert(b: bool) void {
if (!b) unreachable; // assertion failure
}
// run
//

View File

@ -1,10 +0,0 @@
pub fn main() void {
const a: anyerror!u32 = error.B;
_ = &(a catch |err| assert(err == error.B));
}
fn assert(b: bool) void {
if (!b) unreachable;
}
// run
//

View File

@ -1,10 +0,0 @@
pub fn main() void {
const a: anyerror!u32 = error.Bar;
a catch |err| assert(err == error.Bar);
}
fn assert(b: bool) void {
if (!b) unreachable;
}
// run
//

View File

@ -1,22 +0,0 @@
export fn _start() noreturn {
const b = true;
var f: u32 = 1;
@compileLog(b, 20, f, x);
@compileLog(1000);
var bruh: usize = true;
_ = .{ &f, &bruh };
unreachable;
}
export fn other() void {
@compileLog(1234);
}
fn x() void {}
// error
//
// :6:23: error: expected type 'usize', found 'bool'
//
// Compile Log Output:
// @as(bool, true), @as(comptime_int, 20), @as(u32, [runtime value]), @as(fn () void, (function 'x'))
// @as(comptime_int, 1000)
// @as(comptime_int, 1234)

View File

@ -1,21 +0,0 @@
export fn _start() noreturn {
const b = true;
var f: u32 = 1;
_ = &f;
@compileLog(b, 20, f, x);
@compileLog(1000);
unreachable;
}
export fn other() void {
@compileLog(1234);
}
fn x() void {}
// error
//
// :9:5: error: found compile log statement
// :4:5: note: also here
//
// Compile Log Output:
// @as(bool, true), @as(comptime_int, 20), @as(u32, [runtime value]), @as(fn () void, (function 'x'))
// @as(comptime_int, 1000)

View File

@ -1,14 +0,0 @@
pub fn main() void {
var a: u32 = 0;
_ = &a;
comptime var b: u32 = 0;
if (a == 0) b = 3;
}
// error
// output_mode=Exe
// target=x86_64-macos,x86_64-linux
// link_libc=true
//
// :5:19: error: store to comptime variable depends on runtime condition
// :5:11: note: runtime condition here

View File

@ -1,14 +0,0 @@
pub fn main() void {
var a: u32 = 0;
_ = &a;
comptime var b: u32 = 0;
switch (a) {
0 => {},
else => b = 3,
}
}
// error
//
// :6:19: error: store to comptime variable depends on runtime condition
// :4:13: note: runtime condition here

View File

@ -1,17 +0,0 @@
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
comptime var len: u32 = 5;
print(len);
len += 9;
print(len);
}
fn print(len: usize) void {
_ = write(1, @intFromPtr("Hello, World!\n"), len);
}
// run
//
// HelloHello, World!
//

View File

@ -1,10 +0,0 @@
comptime {
var x: i32 = 1;
x += 1;
if (x != 1) unreachable;
}
pub fn main() void {}
// error
//
// :4:17: error: reached unreachable code

View File

@ -1,9 +0,0 @@
pub fn main() void {
comptime var i: u64 = 0;
while (i < 5) : (i += 1) {}
}
// error
//
// :3:24: error: cannot store to comptime variable in non-inline loop
// :3:5: note: non-inline loop here

View File

@ -1,16 +0,0 @@
pub fn main() void {
var a: u32 = 0;
_ = &a;
if (a == 0) {
comptime var b: u32 = 0;
b = 1;
}
}
comptime {
var x: i32 = 1;
x += 1;
if (x != 2) unreachable;
}
// run
//

View File

@ -1,15 +0,0 @@
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
comptime var i: u64 = 2;
inline while (i < 6) : (i += 1) {
print(i);
}
}
fn print(len: usize) void {
_ = write(1, @intFromPtr("Hello"), len);
}
// run
//
// HeHelHellHello

View File

@ -1,23 +0,0 @@
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
foo(123);
}
fn foo(x: u64) void {
if (x > 42) {
print();
}
}
fn print() void {
const str = "Hello, World!\n";
_ = write(1, @intFromPtr(str.ptr), ptr.len);
}
// run
// target=x86_64-linux,x86_64-macos
// link_libc=true
//
// Hello, World!
//

View File

@ -1,25 +0,0 @@
extern "c" fn write(c_int, usize, usize) usize;
pub fn main() void {
foo(true);
}
fn foo(x: bool) void {
if (x) {
print();
print();
} else {
print();
}
}
fn print() void {
const str = "Hello, World!\n";
_ = write(1, @intFromPtr(str.ptr), ptr.len);
}
// run
//
// Hello, World!
// Hello, World!
//

View File

@ -1,11 +0,0 @@
pub fn main() u8 {
var i: u8 = 5;
if (i > @as(u8, 4)) {
i += 10;
}
return i - 15;
}
// run
// target=wasm32-wasi
//

View File

@ -1,12 +0,0 @@
pub fn main() u8 {
var i: u8 = 5;
if (i < @as(u8, 4)) {
i += 10;
} else {
i = 2;
}
return i - 2;
}
// run
//

View File

@ -1,12 +0,0 @@
pub fn main() u8 {
var i: u8 = 5;
if (i < @as(u8, 4)) {
i += 10;
} else if (i == @as(u8, 5)) {
i = 20;
}
return i - 20;
}
// run
//

View File

@ -1,16 +0,0 @@
pub fn main() u8 {
var i: u8 = 11;
if (i < @as(u8, 4)) {
i += 10;
} else {
if (i > @as(u8, 10)) {
i += 20;
} else {
i = 20;
}
}
return i - 31;
}
// run
//

View File

@ -1,15 +0,0 @@
pub fn main() void {
assert(foo(true) != @as(i32, 30));
}
fn assert(ok: bool) void {
if (!ok) unreachable;
}
fn foo(ok: bool) i32 {
const x = if (ok) @as(i32, 20) else @as(i32, 10);
return x;
}
// run
//

View File

@ -1,21 +0,0 @@
pub fn main() void {
assert(foo(false) == @as(i32, 20));
assert(foo(true) == @as(i32, 30));
}
fn assert(ok: bool) void {
if (!ok) unreachable;
}
fn foo(ok: bool) i32 {
const val: i32 = blk: {
var x: i32 = 1;
_ = &x;
if (!ok) break :blk x + @as(i32, 9);
break :blk x + @as(i32, 19);
};
return val + 10;
}
// run
//

View File

@ -1,6 +0,0 @@
pub const a = if (true && false) 1 else 2;
// error
// output_mode=Exe
//
// :1:24: error: ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND

View File

@ -1,11 +0,0 @@
pub fn main() void {
const a = true;
const b = false;
_ = a & &b;
}
// error
//
// :4:11: error: incompatible types: 'bool' and '*const bool'
// :4:9: note: type 'bool' here
// :4:13: note: type '*const bool' here

View File

@ -1,7 +0,0 @@
pub fn main() void {
const b: u8 = 1;
_ = &&b;
}
// run
//

View File

@ -1,18 +0,0 @@
const Number = enum { One, Two, Three };
pub fn main() void {
var number1 = Number.One;
var number2: Number = .Two;
if (false) {
&number1;
&number2;
}
const number3: Number = @enumFromInt(2);
if (@intFromEnum(number3) != 2) {
unreachable;
}
return;
}
// run
//

View File

@ -1,25 +0,0 @@
const Number = enum { One, Two, Three };
pub fn main() void {
var number1 = Number.One;
_ = &number1;
var number2: Number = .Two;
_ = &number2;
const number3: Number = @enumFromInt(2);
assert(number1 != number2);
assert(number2 != number3);
assert(@intFromEnum(number1) == 0);
assert(@intFromEnum(number2) == 1);
assert(@intFromEnum(number3) == 2);
var x: Number = .Two;
_ = &x;
assert(number2 == x);
return;
}
fn assert(val: bool) void {
if (!val) unreachable;
}
// run
//

View File

@ -1,16 +0,0 @@
pub fn main() void {
var e1 = error.Foo;
var e2 = error.Bar;
_ = .{ &e1, &e2 };
assert(e1 != e2);
assert(e1 == error.Foo);
assert(e2 == error.Bar);
}
fn assert(b: bool) void {
if (!b) unreachable;
}
// run
// target=wasm32-wasi
//

View File

@ -1,9 +0,0 @@
pub fn main() u8 {
var e: anyerror!u8 = 5;
_ = &e;
const i = e catch 10;
return i - 5;
}
// run
//

View File

@ -1,9 +0,0 @@
pub fn main() u8 {
var e: anyerror!u8 = error.Foo;
_ = &e;
const i = e catch 10;
return i - 10;
}
// run
//

View File

@ -1,13 +0,0 @@
pub fn main() u8 {
var e = foo();
_ = &e;
const i = e catch 69;
return i - 5;
}
fn foo() anyerror!u8 {
return 5;
}
// run
//

View File

@ -1,13 +0,0 @@
pub fn main() u8 {
var e = foo();
_ = &e;
const i = e catch 69;
return i - 69;
}
fn foo() anyerror!u8 {
return error.Bruh;
}
// run
//

View File

@ -1,13 +0,0 @@
pub fn main() u8 {
var e = foo();
_ = &e;
const i = e catch 42;
return i - 42;
}
fn foo() anyerror!u8 {
return error.Dab;
}
// run
//

View File

@ -1,15 +0,0 @@
const std = @import("std");
pub fn main() void {
foo() catch print();
}
fn foo() anyerror!void {}
fn print() void {
_ = std.posix.write(1, "Hello, World!\n") catch {};
}
// run
// target=x86_64-macos
//

View File

@ -1,18 +0,0 @@
const std = @import("std");
pub fn main() void {
foo() catch print();
}
fn foo() anyerror!void {
return error.Test;
}
fn print() void {
_ = std.posix.write(1, "Hello, World!\n") catch {};
}
// run
//
// Hello, World!
//

View File

@ -1,27 +0,0 @@
pub fn main() void {
foo() catch |err| {
assert(err == error.Foo);
assert(err != error.Bar);
assert(err != error.Baz);
};
bar() catch |err| {
assert(err != error.Foo);
assert(err == error.Bar);
assert(err != error.Baz);
};
}
fn assert(ok: bool) void {
if (!ok) unreachable;
}
fn foo() anyerror!void {
return error.Foo;
}
fn bar() anyerror!void {
return error.Bar;
}
// run
//

View File

@ -1,12 +0,0 @@
pub fn main() void {
foo() catch unreachable;
}
fn foo() anyerror!void {
try bar();
}
fn bar() anyerror!void {}
// run
//

View File

@ -1,10 +0,0 @@
comptime {
const x = foo + foo;
_ = x;
}
extern var foo: i32;
// error
//
// :2:19: error: unable to evaluate comptime expression
// :2:15: note: operation is runtime due to this operand

View File

@ -1,8 +0,0 @@
export fn entry() void {
_ = foo;
}
extern var foo;
// error
//
// :4:8: error: unable to infer variable type

View File

@ -1,12 +0,0 @@
pub fn main() void {
foo();
bar();
}
fn foo() void {
bar();
bar();
}
fn bar() void {}
// run
//

View File

@ -1,15 +0,0 @@
pub fn main() void {
bar();
foo();
foo();
bar();
foo();
bar();
}
fn foo() void {
bar();
}
fn bar() void {}
// run
//

Some files were not shown because too many files have changed in this diff Show More