test: update cases to silence 'var is never mutated' errors

This commit is contained in:
mlugg
2023-11-11 07:27:31 +00:00
parent 2c1acb6180
commit 21fa187abc
289 changed files with 671 additions and 489 deletions

View File

@@ -1,10 +1,10 @@
export fn entry() void {
var frame: @Frame(func) = undefined;
_ = frame;
_ = &frame;
}
fn func(comptime T: type) void {
var x: T = undefined;
_ = x;
_ = &x;
}
// error

View File

@@ -3,7 +3,7 @@ export fn entry() void {
}
fn amain() callconv(.Async) void {
var x: [@sizeOf(@Frame(amain))]u8 = undefined;
_ = x;
_ = &x;
}
// error

View File

@@ -6,7 +6,7 @@ fn amain() callconv(.Async) void {
}
fn other() void {
var x: [@sizeOf(@Frame(amain))]u8 = undefined;
_ = x;
_ = &x;
}
// error

View File

@@ -2,6 +2,7 @@ export fn entry() void {
var ptr: fn () callconv(.Async) void = func;
var bytes: [64]u8 = undefined;
_ = @asyncCall(&bytes, {}, ptr, .{});
_ = &ptr;
}
fn func() callconv(.Async) void {}

View File

@@ -5,7 +5,7 @@ export fn a() void {
export fn b() void {
const f = async func();
var x: anyframe = &f;
_ = x;
_ = &x;
}
fn func() void {
suspend {}

View File

@@ -12,7 +12,7 @@ fn rangeSum(x: i32) i32 {
frame = null;
if (x == 0) return 0;
var child = rangeSumIndirect(x - 1);
const child = rangeSumIndirect(x - 1);
return child + 1;
}
@@ -23,7 +23,7 @@ fn rangeSumIndirect(x: i32) i32 {
frame = null;
if (x == 0) return 0;
var child = rangeSum(x - 1);
const child = rangeSum(x - 1);
return child + 1;
}
@@ -32,5 +32,5 @@ fn rangeSumIndirect(x: i32) i32 {
// target=native
//
// tmp.zig:8:1: error: '@Frame(rangeSum)' depends on itself
// tmp.zig:15:33: note: when analyzing type '@Frame(rangeSum)' here
// tmp.zig:26:25: note: when analyzing type '@Frame(rangeSumIndirect)' here
// tmp.zig:15:35: note: when analyzing type '@Frame(rangeSum)' here
// tmp.zig:28:25: note: when analyzing type '@Frame(rangeSumIndirect)' here

View File

@@ -1,7 +1,7 @@
export fn entry() void {
var frame = async func();
var result = await frame;
_ = result;
_ = &result;
}
fn func() void {
suspend {}

View File

@@ -2,6 +2,7 @@ export fn entry() void {
var ptr = afunc;
var bytes: [100]u8 align(16) = undefined;
_ = @asyncCall(&bytes, {}, ptr, .{});
_ = &ptr;
}
fn afunc() void {}

View File

@@ -1,17 +1,17 @@
export fn a() void {
var x: anyframe = undefined;
var y: anyframe->i32 = x;
_ = y;
_ = .{ &x, &y };
}
export fn b() void {
var x: i32 = undefined;
var y: anyframe->i32 = x;
_ = y;
_ = .{ &x, &y };
}
export fn c() void {
var x: @Frame(func) = undefined;
var y: anyframe->i32 = &x;
_ = y;
_ = .{ &x, &y };
}
fn func() void {}

View File

@@ -4,6 +4,7 @@ export fn entry() void {
fn amain() void {
var ptr = afunc;
_ = ptr();
_ = &ptr;
}
fn afunc() callconv(.Async) void {}

View File

@@ -1,6 +1,7 @@
export fn entry() void {
var ptr = afunc;
_ = async ptr();
_ = &ptr;
}
fn afunc() callconv(.Async) void {}