mirror of
https://github.com/ziglang/zig.git
synced 2025-12-15 18:53:07 +00:00
test: update cases to silence 'var is never mutated' errors
This commit is contained in:
parent
2c1acb6180
commit
21fa187abc
@ -1,5 +1,6 @@
|
|||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
var x: usize = 3;
|
var x: usize = 3;
|
||||||
|
_ = &x;
|
||||||
const y = add(1, 2, x);
|
const y = add(1, 2, x);
|
||||||
if (y - 6 != 0) unreachable;
|
if (y - 6 != 0) unreachable;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ const std = @import("std");
|
|||||||
|
|
||||||
noinline fn outer() u32 {
|
noinline fn outer() u32 {
|
||||||
var a: u32 = 42;
|
var a: u32 = 42;
|
||||||
|
_ = &a;
|
||||||
return inner(.{
|
return inner(.{
|
||||||
.unused = a,
|
.unused = a,
|
||||||
.value = [1]u32{0},
|
.value = [1]u32{0},
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
var i: u64 = 0xFFEEDDCCBBAA9988;
|
var i: u64 = 0xFFEEDDCCBBAA9988;
|
||||||
|
_ = &i;
|
||||||
assert(i == 0xFFEEDDCCBBAA9988);
|
assert(i == 0xFFEEDDCCBBAA9988);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
var x = null;
|
var x = null;
|
||||||
_ = x;
|
_ = &x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
var i: i32 = 2147483647;
|
var i: i32 = 2147483647;
|
||||||
|
_ = &i;
|
||||||
if (i +% 1 != -2147483648) unreachable;
|
if (i +% 1 != -2147483648) unreachable;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ pub fn main() void {
|
|||||||
var i: u32 = 5;
|
var i: u32 = 5;
|
||||||
i *= 7;
|
i *= 7;
|
||||||
var result: u32 = foo(i, 10);
|
var result: u32 = foo(i, 10);
|
||||||
|
_ = &result;
|
||||||
if (result != 350) unreachable;
|
if (result != 350) unreachable;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
var i: i32 = 2147483647;
|
var i: i32 = 2147483647;
|
||||||
|
_ = &i;
|
||||||
const result = i *% 2;
|
const result = i *% 2;
|
||||||
if (result != -2) unreachable;
|
if (result != -2) unreachable;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
var i: u3 = 3;
|
var i: u3 = 3;
|
||||||
|
_ = &i;
|
||||||
if (i *% 3 != 1) unreachable;
|
if (i *% 3 != 1) unreachable;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
var i: i4 = 3;
|
var i: i4 = 3;
|
||||||
|
_ = &i;
|
||||||
if (i *% 3 != -7) unreachable;
|
if (i *% 3 != -7) unreachable;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
var i: u32 = 352;
|
var i: u32 = 352;
|
||||||
i /= 7; // i = 50
|
i /= 7; // i = 50
|
||||||
var result: u32 = foo(i, 7);
|
const result: u32 = foo(i, 7);
|
||||||
if (result != 7) unreachable;
|
if (result != 7) unreachable;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
var i: i4 = 7;
|
var i: i4 = 7;
|
||||||
|
_ = &i;
|
||||||
if (i +% 1 != -8) unreachable;
|
if (i +% 1 != -8) unreachable;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pub fn main() u8 {
|
pub fn main() u8 {
|
||||||
var i: u8 = 255;
|
var i: u8 = 255;
|
||||||
|
_ = &i;
|
||||||
return i +% 1;
|
return i +% 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
pub fn main() u8 {
|
pub fn main() u8 {
|
||||||
var i: u8 = 5;
|
var i: u8 = 5;
|
||||||
i += 20;
|
i += 20;
|
||||||
var result: u8 = foo(i, 10);
|
const result: u8 = foo(i, 10);
|
||||||
return result - 35;
|
return result - 35;
|
||||||
}
|
}
|
||||||
fn foo(x: u8, y: u8) u8 {
|
fn foo(x: u8, y: u8) u8 {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
var i: i32 = -2147483648;
|
var i: i32 = -2147483648;
|
||||||
|
_ = &i;
|
||||||
if (i -% 1 != 2147483647) unreachable;
|
if (i -% 1 != 2147483647) unreachable;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
var i: i7 = -64;
|
var i: i7 = -64;
|
||||||
|
_ = &i;
|
||||||
if (i -% 1 != 63) unreachable;
|
if (i -% 1 != 63) unreachable;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pub fn main() void {
|
pub fn main() void {
|
||||||
var i: u4 = 0;
|
var i: u4 = 0;
|
||||||
|
_ = &i;
|
||||||
if (i -% 1 != 15) unreachable;
|
if (i -% 1 != 15) unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ pub fn main() u8 {
|
|||||||
var i: u8 = 5;
|
var i: u8 = 5;
|
||||||
i -= 3;
|
i -= 3;
|
||||||
var result: u8 = foo(i, 10);
|
var result: u8 = foo(i, 10);
|
||||||
|
_ = &result;
|
||||||
return result - 8;
|
return result - 8;
|
||||||
}
|
}
|
||||||
fn foo(x: u8, y: u8) u8 {
|
fn foo(x: u8, y: u8) u8 {
|
||||||
|
|||||||
@ -2,7 +2,8 @@ export fn entry() void {
|
|||||||
const U = union { A: u32, B: u64 };
|
const U = union { A: u32, B: u64 };
|
||||||
var u = U{ .A = 42 };
|
var u = U{ .A = 42 };
|
||||||
var ok = u == .A;
|
var ok = u == .A;
|
||||||
_ = ok;
|
_ = &u;
|
||||||
|
_ = &ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -6,7 +6,7 @@ const S2 = struct {
|
|||||||
};
|
};
|
||||||
pub export fn entry() void {
|
pub export fn entry() void {
|
||||||
var s: S1 = undefined;
|
var s: S1 = undefined;
|
||||||
_ = s;
|
_ = &s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
const Foo = struct { a: u32 };
|
const Foo = struct { a: u32 };
|
||||||
export fn a() void {
|
export fn a() void {
|
||||||
const T = [*c]Foo;
|
const T = [*c]Foo;
|
||||||
var t: T = undefined;
|
const t: T = undefined;
|
||||||
_ = t;
|
_ = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
export fn a() void {
|
export fn a() void {
|
||||||
var x: *anyopaque = undefined;
|
var x: *anyopaque = undefined;
|
||||||
var y: [*c]anyopaque = x;
|
var y: [*c]anyopaque = x;
|
||||||
_ = y;
|
_ = .{ &x, &y };
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -7,8 +7,8 @@ fn outer(y: u32) *const fn (u32) u32 {
|
|||||||
return st.get;
|
return st.get;
|
||||||
}
|
}
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var func = outer(10);
|
const func = outer(10);
|
||||||
var x = func(3);
|
const x = func(3);
|
||||||
_ = x;
|
_ = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
comptime {
|
comptime {
|
||||||
var a: i64 = undefined;
|
const a: i64 = undefined;
|
||||||
_ = a + a;
|
_ = a + a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ const Number = enum {
|
|||||||
// zig fmt: on
|
// zig fmt: on
|
||||||
|
|
||||||
export fn entry1() void {
|
export fn entry1() void {
|
||||||
var x: Number = undefined;
|
const x: Number = undefined;
|
||||||
_ = x;
|
_ = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
export fn entry1() void {
|
export fn entry1() void {
|
||||||
var f: f32 = 54.0 / 5;
|
const f: f32 = 54.0 / 5;
|
||||||
_ = f;
|
_ = f;
|
||||||
}
|
}
|
||||||
export fn entry2() void {
|
export fn entry2() void {
|
||||||
var f: f32 = 54 / 5.0;
|
const f: f32 = 54 / 5.0;
|
||||||
_ = f;
|
_ = f;
|
||||||
}
|
}
|
||||||
export fn entry3() void {
|
export fn entry3() void {
|
||||||
var f: f32 = 55.0 / 5;
|
const f: f32 = 55.0 / 5;
|
||||||
_ = f;
|
_ = f;
|
||||||
}
|
}
|
||||||
export fn entry4() void {
|
export fn entry4() void {
|
||||||
var f: f32 = 55 / 5.0;
|
const f: f32 = 55 / 5.0;
|
||||||
_ = f;
|
_ = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,5 +19,5 @@ export fn entry4() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :2:23: error: ambiguous coercion of division operands 'comptime_float' and 'comptime_int'; non-zero remainder '4'
|
// :2:25: error: ambiguous coercion of division operands 'comptime_float' and 'comptime_int'; non-zero remainder '4'
|
||||||
// :6:21: error: ambiguous coercion of division operands 'comptime_int' and 'comptime_float'; non-zero remainder '4'
|
// :6:23: error: ambiguous coercion of division operands 'comptime_int' and 'comptime_float'; non-zero remainder '4'
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
comptime {
|
comptime {
|
||||||
var a: bool = undefined;
|
var a: bool = undefined;
|
||||||
|
_ = &a;
|
||||||
_ = a and a;
|
_ = a and a;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7,4 +8,4 @@ comptime {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :3:9: error: use of undefined value here causes undefined behavior
|
// :4:9: error: use of undefined value here causes undefined behavior
|
||||||
|
|||||||
@ -3,7 +3,7 @@ export fn f() void {
|
|||||||
bad[0] = bad[0];
|
bad[0] = bad[0];
|
||||||
}
|
}
|
||||||
export fn g() void {
|
export fn g() void {
|
||||||
var bad: bool = undefined;
|
const bad: bool = undefined;
|
||||||
_ = bad[0];
|
_ = bad[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
export fn foo() void {
|
export fn foo() void {
|
||||||
var b: u8[40] = undefined;
|
var b: u8[40] = undefined;
|
||||||
_ = b;
|
_ = &b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -2,11 +2,13 @@ export fn f() void {
|
|||||||
var array = "aoeu";
|
var array = "aoeu";
|
||||||
var bad = false;
|
var bad = false;
|
||||||
array[bad] = array[bad];
|
array[bad] = array[bad];
|
||||||
|
_ = &bad;
|
||||||
}
|
}
|
||||||
export fn g() void {
|
export fn g() void {
|
||||||
var array = "aoeu";
|
var array = "aoeu";
|
||||||
var bad = false;
|
var bad = false;
|
||||||
_ = array[bad];
|
_ = array[bad];
|
||||||
|
_ = .{ &array, &bad };
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
@ -14,4 +16,4 @@ export fn g() void {
|
|||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :4:11: error: expected type 'usize', found 'bool'
|
// :4:11: error: expected type 'usize', found 'bool'
|
||||||
// :9:15: error: expected type 'usize', found 'bool'
|
// :10:15: error: expected type 'usize', found 'bool'
|
||||||
|
|||||||
@ -2,27 +2,27 @@ const V = @Vector(8, u8);
|
|||||||
const A = [8]u8;
|
const A = [8]u8;
|
||||||
comptime {
|
comptime {
|
||||||
var v: V = V{1};
|
var v: V = V{1};
|
||||||
_ = v;
|
_ = &v;
|
||||||
}
|
}
|
||||||
comptime {
|
comptime {
|
||||||
var v: V = V{};
|
var v: V = V{};
|
||||||
_ = v;
|
_ = &v;
|
||||||
}
|
}
|
||||||
comptime {
|
comptime {
|
||||||
var a: A = A{1};
|
var a: A = A{1};
|
||||||
_ = a;
|
_ = &a;
|
||||||
}
|
}
|
||||||
comptime {
|
comptime {
|
||||||
var a: A = A{};
|
var a: A = A{};
|
||||||
_ = a;
|
_ = &a;
|
||||||
}
|
}
|
||||||
pub export fn entry1() void {
|
pub export fn entry1() void {
|
||||||
var bla: V = .{ 1, 2, 3, 4 };
|
var bla: V = .{ 1, 2, 3, 4 };
|
||||||
_ = bla;
|
_ = &bla;
|
||||||
}
|
}
|
||||||
pub export fn entry2() void {
|
pub export fn entry2() void {
|
||||||
var bla: A = .{ 1, 2, 3, 4 };
|
var bla: A = .{ 1, 2, 3, 4 };
|
||||||
_ = bla;
|
_ = &bla;
|
||||||
}
|
}
|
||||||
const S = struct {
|
const S = struct {
|
||||||
list: [2]u8 = .{0},
|
list: [2]u8 = .{0},
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var a = &b;
|
var a = &b;
|
||||||
_ = a;
|
_ = &a;
|
||||||
}
|
}
|
||||||
inline fn b() void {}
|
inline fn b() void {}
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ export fn constEntry() u32 {
|
|||||||
|
|
||||||
export fn varEntry() u32 {
|
export fn varEntry() u32 {
|
||||||
var x: u32 = g();
|
var x: u32 = g();
|
||||||
return x;
|
return (&x).*;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
export fn foo() void {
|
export fn foo() void {
|
||||||
var vga_mem: u16 = 0xB8000;
|
const vga_mem: u16 = 0xB8000;
|
||||||
_ = vga_mem;
|
_ = vga_mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7,4 +7,4 @@ export fn foo() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :2:24: error: type 'u16' cannot represent integer value '753664'
|
// :2:26: error: type 'u16' cannot represent integer value '753664'
|
||||||
|
|||||||
@ -10,8 +10,8 @@ const S = struct {
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var u = U{ .Ye = maybe(false) };
|
var u = U{ .Ye = maybe(false) };
|
||||||
var s = S{ .num = maybe(false) };
|
var s = S{ .num = maybe(false) };
|
||||||
_ = u;
|
_ = &u;
|
||||||
_ = s;
|
_ = &s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var frame: @Frame(func) = undefined;
|
var frame: @Frame(func) = undefined;
|
||||||
_ = frame;
|
_ = &frame;
|
||||||
}
|
}
|
||||||
fn func(comptime T: type) void {
|
fn func(comptime T: type) void {
|
||||||
var x: T = undefined;
|
var x: T = undefined;
|
||||||
_ = x;
|
_ = &x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -3,7 +3,7 @@ export fn entry() void {
|
|||||||
}
|
}
|
||||||
fn amain() callconv(.Async) void {
|
fn amain() callconv(.Async) void {
|
||||||
var x: [@sizeOf(@Frame(amain))]u8 = undefined;
|
var x: [@sizeOf(@Frame(amain))]u8 = undefined;
|
||||||
_ = x;
|
_ = &x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -6,7 +6,7 @@ fn amain() callconv(.Async) void {
|
|||||||
}
|
}
|
||||||
fn other() void {
|
fn other() void {
|
||||||
var x: [@sizeOf(@Frame(amain))]u8 = undefined;
|
var x: [@sizeOf(@Frame(amain))]u8 = undefined;
|
||||||
_ = x;
|
_ = &x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -2,6 +2,7 @@ export fn entry() void {
|
|||||||
var ptr: fn () callconv(.Async) void = func;
|
var ptr: fn () callconv(.Async) void = func;
|
||||||
var bytes: [64]u8 = undefined;
|
var bytes: [64]u8 = undefined;
|
||||||
_ = @asyncCall(&bytes, {}, ptr, .{});
|
_ = @asyncCall(&bytes, {}, ptr, .{});
|
||||||
|
_ = &ptr;
|
||||||
}
|
}
|
||||||
fn func() callconv(.Async) void {}
|
fn func() callconv(.Async) void {}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ export fn a() void {
|
|||||||
export fn b() void {
|
export fn b() void {
|
||||||
const f = async func();
|
const f = async func();
|
||||||
var x: anyframe = &f;
|
var x: anyframe = &f;
|
||||||
_ = x;
|
_ = &x;
|
||||||
}
|
}
|
||||||
fn func() void {
|
fn func() void {
|
||||||
suspend {}
|
suspend {}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ fn rangeSum(x: i32) i32 {
|
|||||||
frame = null;
|
frame = null;
|
||||||
|
|
||||||
if (x == 0) return 0;
|
if (x == 0) return 0;
|
||||||
var child = rangeSumIndirect(x - 1);
|
const child = rangeSumIndirect(x - 1);
|
||||||
return child + 1;
|
return child + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ fn rangeSumIndirect(x: i32) i32 {
|
|||||||
frame = null;
|
frame = null;
|
||||||
|
|
||||||
if (x == 0) return 0;
|
if (x == 0) return 0;
|
||||||
var child = rangeSum(x - 1);
|
const child = rangeSum(x - 1);
|
||||||
return child + 1;
|
return child + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,5 +32,5 @@ fn rangeSumIndirect(x: i32) i32 {
|
|||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// tmp.zig:8:1: error: '@Frame(rangeSum)' depends on itself
|
// tmp.zig:8:1: error: '@Frame(rangeSum)' depends on itself
|
||||||
// tmp.zig:15:33: note: when analyzing type '@Frame(rangeSum)' here
|
// tmp.zig:15:35: note: when analyzing type '@Frame(rangeSum)' here
|
||||||
// tmp.zig:26:25: note: when analyzing type '@Frame(rangeSumIndirect)' here
|
// tmp.zig:28:25: note: when analyzing type '@Frame(rangeSumIndirect)' here
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var frame = async func();
|
var frame = async func();
|
||||||
var result = await frame;
|
var result = await frame;
|
||||||
_ = result;
|
_ = &result;
|
||||||
}
|
}
|
||||||
fn func() void {
|
fn func() void {
|
||||||
suspend {}
|
suspend {}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ export fn entry() void {
|
|||||||
var ptr = afunc;
|
var ptr = afunc;
|
||||||
var bytes: [100]u8 align(16) = undefined;
|
var bytes: [100]u8 align(16) = undefined;
|
||||||
_ = @asyncCall(&bytes, {}, ptr, .{});
|
_ = @asyncCall(&bytes, {}, ptr, .{});
|
||||||
|
_ = &ptr;
|
||||||
}
|
}
|
||||||
fn afunc() void {}
|
fn afunc() void {}
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,17 @@
|
|||||||
export fn a() void {
|
export fn a() void {
|
||||||
var x: anyframe = undefined;
|
var x: anyframe = undefined;
|
||||||
var y: anyframe->i32 = x;
|
var y: anyframe->i32 = x;
|
||||||
_ = y;
|
_ = .{ &x, &y };
|
||||||
}
|
}
|
||||||
export fn b() void {
|
export fn b() void {
|
||||||
var x: i32 = undefined;
|
var x: i32 = undefined;
|
||||||
var y: anyframe->i32 = x;
|
var y: anyframe->i32 = x;
|
||||||
_ = y;
|
_ = .{ &x, &y };
|
||||||
}
|
}
|
||||||
export fn c() void {
|
export fn c() void {
|
||||||
var x: @Frame(func) = undefined;
|
var x: @Frame(func) = undefined;
|
||||||
var y: anyframe->i32 = &x;
|
var y: anyframe->i32 = &x;
|
||||||
_ = y;
|
_ = .{ &x, &y };
|
||||||
}
|
}
|
||||||
fn func() void {}
|
fn func() void {}
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ export fn entry() void {
|
|||||||
fn amain() void {
|
fn amain() void {
|
||||||
var ptr = afunc;
|
var ptr = afunc;
|
||||||
_ = ptr();
|
_ = ptr();
|
||||||
|
_ = &ptr;
|
||||||
}
|
}
|
||||||
fn afunc() callconv(.Async) void {}
|
fn afunc() callconv(.Async) void {}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var ptr = afunc;
|
var ptr = afunc;
|
||||||
_ = async ptr();
|
_ = async ptr();
|
||||||
|
_ = &ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn afunc() callconv(.Async) void {}
|
fn afunc() callconv(.Async) void {}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
export fn entry(byte: u8) void {
|
export fn entry() void {
|
||||||
const w: i32 = 1234;
|
const w: i32 = 1234;
|
||||||
var x: *const i32 = &w;
|
var x: *const i32 = &w;
|
||||||
var y: *[1]i32 = x;
|
var y: *[1]i32 = x;
|
||||||
y[0] += 1;
|
y[0] += 1;
|
||||||
_ = byte;
|
_ = &x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
export fn a() void {
|
export fn a() void {
|
||||||
var x: [10]u8 = undefined;
|
var x: [10]u8 = undefined;
|
||||||
var y: []align(16) u8 = &x;
|
const y: []align(16) u8 = &x;
|
||||||
_ = y;
|
_ = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8,5 +8,5 @@ export fn a() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :3:29: error: expected type '[]align(16) u8', found '*[10]u8'
|
// :3:31: error: expected type '[]align(16) u8', found '*[10]u8'
|
||||||
// :3:29: note: pointer alignment '1' cannot cast into pointer alignment '16'
|
// :3:31: note: pointer alignment '1' cannot cast into pointer alignment '16'
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
export fn entry1() void {
|
export fn entry1() void {
|
||||||
var x: []align(true) i32 = undefined;
|
const x: []align(true) i32 = undefined;
|
||||||
_ = x;
|
_ = x;
|
||||||
}
|
}
|
||||||
export fn entry2() void {
|
export fn entry2() void {
|
||||||
var x: *align(@as(f64, 12.34)) i32 = undefined;
|
const x: *align(@as(f64, 12.34)) i32 = undefined;
|
||||||
_ = x;
|
_ = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11,5 +11,5 @@ export fn entry2() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :2:20: error: expected type 'u32', found 'bool'
|
// :2:22: error: expected type 'u32', found 'bool'
|
||||||
// :6:19: error: fractional component prevents float value '12.34' from coercion to type 'u32'
|
// :6:21: error: fractional component prevents float value '12.34' from coercion to type 'u32'
|
||||||
|
|||||||
@ -11,7 +11,7 @@ export fn entry4() void {
|
|||||||
@call(.never_inline, bar, .{});
|
@call(.never_inline, bar, .{});
|
||||||
}
|
}
|
||||||
export fn entry5(c: bool) void {
|
export fn entry5(c: bool) void {
|
||||||
var baz = if (c) &baz1 else &baz2;
|
const baz = if (c) &baz1 else &baz2;
|
||||||
@call(.compile_time, baz, .{});
|
@call(.compile_time, baz, .{});
|
||||||
}
|
}
|
||||||
export fn entry6() void {
|
export fn entry6() void {
|
||||||
@ -22,6 +22,7 @@ export fn entry7() void {
|
|||||||
}
|
}
|
||||||
pub export fn entry() void {
|
pub export fn entry() void {
|
||||||
var call_me: *const fn () void = undefined;
|
var call_me: *const fn () void = undefined;
|
||||||
|
_ = &call_me;
|
||||||
@call(.always_inline, call_me, .{});
|
@call(.always_inline, call_me, .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,4 +46,4 @@ noinline fn dummy2() void {}
|
|||||||
// :15:26: error: modifier 'compile_time' requires a comptime-known function
|
// :15:26: error: modifier 'compile_time' requires a comptime-known function
|
||||||
// :18:9: error: 'always_inline' call of noinline function
|
// :18:9: error: 'always_inline' call of noinline function
|
||||||
// :21:9: error: 'always_inline' call of noinline function
|
// :21:9: error: 'always_inline' call of noinline function
|
||||||
// :25:27: error: modifier 'always_inline' requires a comptime-known function
|
// :26:27: error: modifier 'always_inline' requires a comptime-known function
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
pub const A = error.A;
|
pub const A = error.A;
|
||||||
pub const AB = A | error.B;
|
pub const AB = A | error.B;
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var x: AB = undefined;
|
const x: AB = undefined;
|
||||||
_ = x;
|
_ = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
export fn entry(byte: u8) void {
|
export fn entry(byte: u8) void {
|
||||||
var oops: u7 = @bitCast(byte);
|
const oops: u7 = @bitCast(byte);
|
||||||
_ = oops;
|
_ = oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7,4 +7,4 @@ export fn entry(byte: u8) void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :2:20: error: @bitCast size mismatch: destination type 'u7' has 7 bits but source type 'u8' has 8 bits
|
// :2:22: error: @bitCast size mismatch: destination type 'u7' has 7 bits but source type 'u8' has 8 bits
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var foo = (@as(u8, @bitCast(@as(f32, 1.0))) == 0xf);
|
const f: f32 = 1.0;
|
||||||
|
const foo = (@as(u8, @bitCast(f)) == 0xf);
|
||||||
_ = foo;
|
_ = foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7,4 +8,4 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :2:24: error: @bitCast size mismatch: destination type 'u8' has 8 bits but source type 'f32' has 32 bits
|
// :3:26: error: @bitCast size mismatch: destination type 'u8' has 8 bits but source type 'f32' has 32 bits
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pub export fn entry1() void {
|
pub export fn entry1() void {
|
||||||
var x: u32 = 3;
|
var x: u32 = 3;
|
||||||
|
_ = &x;
|
||||||
_ = @shuffle(u32, [_]u32{0}, @as(@Vector(1, u32), @splat(0)), [_]i8{
|
_ = @shuffle(u32, [_]u32{0}, @as(@Vector(1, u32), @splat(0)), [_]i8{
|
||||||
if (x > 1) 1 else -1,
|
if (x > 1) 1 else -1,
|
||||||
});
|
});
|
||||||
@ -7,6 +8,7 @@ pub export fn entry1() void {
|
|||||||
|
|
||||||
pub export fn entry2() void {
|
pub export fn entry2() void {
|
||||||
var y: ?i8 = -1;
|
var y: ?i8 = -1;
|
||||||
|
_ = &y;
|
||||||
_ = @shuffle(u32, [_]u32{0}, @as(@Vector(1, u32), @splat(0)), [_]i8{
|
_ = @shuffle(u32, [_]u32{0}, @as(@Vector(1, u32), @splat(0)), [_]i8{
|
||||||
y orelse 1,
|
y orelse 1,
|
||||||
});
|
});
|
||||||
@ -16,6 +18,6 @@ pub export fn entry2() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :4:15: error: unable to evaluate comptime expression
|
// :5:15: error: unable to evaluate comptime expression
|
||||||
// :4:13: note: operation is runtime due to this operand
|
// :5:13: note: operation is runtime due to this operand
|
||||||
// :11:11: error: unable to evaluate comptime expression
|
// :13:11: error: unable to evaluate comptime expression
|
||||||
|
|||||||
@ -10,6 +10,7 @@ export fn f2() void {
|
|||||||
}
|
}
|
||||||
export fn f3() void {
|
export fn f3() void {
|
||||||
var t: bool = true;
|
var t: bool = true;
|
||||||
|
_ = &t;
|
||||||
const x: usize = while (t) {
|
const x: usize = while (t) {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
@ -28,5 +29,5 @@ export fn f4() void {
|
|||||||
//
|
//
|
||||||
// :2:22: error: expected type 'usize', found 'void'
|
// :2:22: error: expected type 'usize', found 'void'
|
||||||
// :7:9: error: expected type 'usize', found 'void'
|
// :7:9: error: expected type 'usize', found 'void'
|
||||||
// :14:9: error: expected type 'usize', found 'void'
|
// :15:9: error: expected type 'usize', found 'void'
|
||||||
// :20:9: error: expected type 'usize', found 'void'
|
// :21:9: error: expected type 'usize', found 'void'
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var a: [*c]void = undefined;
|
const a: [*c]void = undefined;
|
||||||
_ = a;
|
_ = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7,5 +7,5 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :2:16: error: C pointers cannot point to non-C-ABI-compatible type 'void'
|
// :2:18: error: C pointers cannot point to non-C-ABI-compatible type 'void'
|
||||||
// :2:16: note: 'void' is a zero bit type; for C 'void' use 'anyopaque'
|
// :2:18: note: 'void' is a zero bit type; for C 'void' use 'anyopaque'
|
||||||
|
|||||||
@ -2,15 +2,15 @@ const F1 = fn () callconv(.Stdcall) void;
|
|||||||
const F2 = fn () callconv(.Fastcall) void;
|
const F2 = fn () callconv(.Fastcall) void;
|
||||||
const F3 = fn () callconv(.Thiscall) void;
|
const F3 = fn () callconv(.Thiscall) void;
|
||||||
export fn entry1() void {
|
export fn entry1() void {
|
||||||
var a: F1 = undefined;
|
const a: F1 = undefined;
|
||||||
_ = a;
|
_ = a;
|
||||||
}
|
}
|
||||||
export fn entry2() void {
|
export fn entry2() void {
|
||||||
var a: F2 = undefined;
|
const a: F2 = undefined;
|
||||||
_ = a;
|
_ = a;
|
||||||
}
|
}
|
||||||
export fn entry3() void {
|
export fn entry3() void {
|
||||||
var a: F3 = undefined;
|
const a: F3 = undefined;
|
||||||
_ = a;
|
_ = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ export fn entry1() void {
|
|||||||
var a: fnty1 = undefined;
|
var a: fnty1 = undefined;
|
||||||
var b: fnty2 = undefined;
|
var b: fnty2 = undefined;
|
||||||
a = b;
|
a = b;
|
||||||
|
_ = &b;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fnty3 = ?*const fn (u63) void;
|
pub const fnty3 = ?*const fn (u63) void;
|
||||||
@ -11,6 +12,7 @@ export fn entry2() void {
|
|||||||
var a: fnty3 = undefined;
|
var a: fnty3 = undefined;
|
||||||
var b: fnty2 = undefined;
|
var b: fnty2 = undefined;
|
||||||
a = b;
|
a = b;
|
||||||
|
_ = &b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
@ -21,6 +23,6 @@ export fn entry2() void {
|
|||||||
// :6:9: note: pointer type child 'fn (u64) void' cannot cast into pointer type child 'fn (i8) void'
|
// :6:9: note: pointer type child 'fn (u64) void' cannot cast into pointer type child 'fn (i8) void'
|
||||||
// :6:9: note: parameter 0 'u64' cannot cast into 'i8'
|
// :6:9: note: parameter 0 'u64' cannot cast into 'i8'
|
||||||
// :6:9: note: unsigned 64-bit int cannot represent all possible signed 8-bit values
|
// :6:9: note: unsigned 64-bit int cannot represent all possible signed 8-bit values
|
||||||
// :13:9: error: expected type '?*const fn (u63) void', found '?*const fn (u64) void'
|
// :14:9: error: expected type '?*const fn (u63) void', found '?*const fn (u64) void'
|
||||||
// :13:9: note: pointer type child 'fn (u64) void' cannot cast into pointer type child 'fn (u63) void'
|
// :14:9: note: pointer type child 'fn (u64) void' cannot cast into pointer type child 'fn (u63) void'
|
||||||
// :13:9: note: parameter 0 'u64' cannot cast into 'u63'
|
// :14:9: note: parameter 0 'u64' cannot cast into 'u63'
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
const SmallErrorSet = error{A};
|
const SmallErrorSet = error{A};
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var x: SmallErrorSet!i32 = foo();
|
const x: SmallErrorSet!i32 = foo();
|
||||||
_ = x;
|
_ = x;
|
||||||
}
|
}
|
||||||
fn foo() anyerror!i32 {
|
fn foo() anyerror!i32 {
|
||||||
@ -11,5 +11,5 @@ fn foo() anyerror!i32 {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :3:35: error: expected type 'error{A}!i32', found 'anyerror!i32'
|
// :3:37: error: expected type 'error{A}!i32', found 'anyerror!i32'
|
||||||
// :3:35: note: global error set cannot cast into a smaller set
|
// :3:37: note: global error set cannot cast into a smaller set
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
const SmallErrorSet = error{A};
|
const SmallErrorSet = error{A};
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var x: SmallErrorSet = foo();
|
const x: SmallErrorSet = foo();
|
||||||
_ = x;
|
_ = x;
|
||||||
}
|
}
|
||||||
fn foo() anyerror {
|
fn foo() anyerror {
|
||||||
@ -11,5 +11,5 @@ fn foo() anyerror {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :3:31: error: expected type 'error{A}', found 'anyerror'
|
// :3:33: error: expected type 'error{A}', found 'anyerror'
|
||||||
// :3:31: note: global error set cannot cast into a smaller set
|
// :3:33: note: global error set cannot cast into a smaller set
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
comptime {
|
comptime {
|
||||||
var a: anyerror!bool = undefined;
|
const a: anyerror!bool = undefined;
|
||||||
if (a catch false) {}
|
if (a catch false) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var x: ?[3]i32 = undefined;
|
const x: ?[3]i32 = undefined;
|
||||||
var y: [3]i32 = undefined;
|
const y: [3]i32 = undefined;
|
||||||
_ = (x == y);
|
_ = (x == y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,36 +1,36 @@
|
|||||||
// operator ==
|
// operator ==
|
||||||
comptime {
|
comptime {
|
||||||
var a: i64 = undefined;
|
const a: i64 = undefined;
|
||||||
var x: i32 = 0;
|
var x: i32 = 0;
|
||||||
if (a == a) x += 1;
|
if (a == a) x += 1;
|
||||||
}
|
}
|
||||||
// operator !=
|
// operator !=
|
||||||
comptime {
|
comptime {
|
||||||
var a: i64 = undefined;
|
const a: i64 = undefined;
|
||||||
var x: i32 = 0;
|
var x: i32 = 0;
|
||||||
if (a != a) x += 1;
|
if (a != a) x += 1;
|
||||||
}
|
}
|
||||||
// operator >
|
// operator >
|
||||||
comptime {
|
comptime {
|
||||||
var a: i64 = undefined;
|
const a: i64 = undefined;
|
||||||
var x: i32 = 0;
|
var x: i32 = 0;
|
||||||
if (a > a) x += 1;
|
if (a > a) x += 1;
|
||||||
}
|
}
|
||||||
// operator <
|
// operator <
|
||||||
comptime {
|
comptime {
|
||||||
var a: i64 = undefined;
|
const a: i64 = undefined;
|
||||||
var x: i32 = 0;
|
var x: i32 = 0;
|
||||||
if (a < a) x += 1;
|
if (a < a) x += 1;
|
||||||
}
|
}
|
||||||
// operator >=
|
// operator >=
|
||||||
comptime {
|
comptime {
|
||||||
var a: i64 = undefined;
|
const a: i64 = undefined;
|
||||||
var x: i32 = 0;
|
var x: i32 = 0;
|
||||||
if (a >= a) x += 1;
|
if (a >= a) x += 1;
|
||||||
}
|
}
|
||||||
// operator <=
|
// operator <=
|
||||||
comptime {
|
comptime {
|
||||||
var a: i64 = undefined;
|
const a: i64 = undefined;
|
||||||
var x: i32 = 0;
|
var x: i32 = 0;
|
||||||
if (a <= a) x += 1;
|
if (a <= a) x += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ const Foo = struct {
|
|||||||
b: i32,
|
b: i32,
|
||||||
};
|
};
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var x = Foo{
|
const x: Foo = .{
|
||||||
.b = 5,
|
.b = 5,
|
||||||
};
|
};
|
||||||
_ = x;
|
_ = x;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
comptime {
|
comptime {
|
||||||
var opt_ptr: ?*i32 = null;
|
const opt_ptr: ?*i32 = null;
|
||||||
const ptr: *i32 = @ptrCast(opt_ptr);
|
const ptr: *i32 = @ptrCast(opt_ptr);
|
||||||
_ = ptr;
|
_ = ptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
comptime {
|
comptime {
|
||||||
var undef_ptr: *i32 = undefined;
|
var undef_ptr: *i32 = undefined;
|
||||||
const ptr: *i32 = @ptrCast(undef_ptr);
|
const ptr: *i32 = @ptrCast(undef_ptr);
|
||||||
|
_ = &undef_ptr;
|
||||||
_ = ptr;
|
_ = ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ const Value = union(Letter) {
|
|||||||
};
|
};
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var x: Value = Letter.A;
|
var x: Value = Letter.A;
|
||||||
_ = x;
|
_ = &x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var p: usize = undefined;
|
var p: usize = undefined;
|
||||||
|
_ = &p;
|
||||||
comptime var q = true;
|
comptime var q = true;
|
||||||
inline while (q) {
|
inline while (q) {
|
||||||
if (p == 11) continue;
|
if (p == 11) continue;
|
||||||
@ -11,5 +12,5 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :5:22: error: comptime control flow inside runtime block
|
// :6:22: error: comptime control flow inside runtime block
|
||||||
// :5:15: note: runtime control flow here
|
// :6:15: note: runtime control flow here
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var p: anyerror!i32 = undefined;
|
var p: anyerror!i32 = undefined;
|
||||||
|
_ = &p;
|
||||||
comptime var q = true;
|
comptime var q = true;
|
||||||
inline while (q) {
|
inline while (q) {
|
||||||
if (p) |_| continue else |_| {}
|
if (p) |_| continue else |_| {}
|
||||||
@ -11,5 +12,5 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :5:20: error: comptime control flow inside runtime block
|
// :6:20: error: comptime control flow inside runtime block
|
||||||
// :5:13: note: runtime control flow here
|
// :6:13: note: runtime control flow here
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var p: ?i32 = undefined;
|
var p: ?i32 = undefined;
|
||||||
|
_ = &p;
|
||||||
comptime var q = true;
|
comptime var q = true;
|
||||||
inline while (q) {
|
inline while (q) {
|
||||||
if (p) |_| continue;
|
if (p) |_| continue;
|
||||||
@ -11,5 +12,5 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :5:20: error: comptime control flow inside runtime block
|
// :6:20: error: comptime control flow inside runtime block
|
||||||
// :5:13: note: runtime control flow here
|
// :6:13: note: runtime control flow here
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var p: i32 = undefined;
|
var p: i32 = undefined;
|
||||||
|
_ = &p;
|
||||||
comptime var q = true;
|
comptime var q = true;
|
||||||
inline while (q) {
|
inline while (q) {
|
||||||
switch (p) {
|
switch (p) {
|
||||||
@ -14,5 +15,5 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :6:19: error: comptime control flow inside runtime block
|
// :7:19: error: comptime control flow inside runtime block
|
||||||
// :5:17: note: runtime control flow here
|
// :6:17: note: runtime control flow here
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var p: usize = undefined;
|
var p: usize = undefined;
|
||||||
|
_ = &p;
|
||||||
comptime var q = true;
|
comptime var q = true;
|
||||||
outer: inline while (q) {
|
outer: inline while (q) {
|
||||||
while (p == 11) continue :outer;
|
while (p == 11) continue :outer;
|
||||||
@ -11,5 +12,5 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :5:25: error: comptime control flow inside runtime block
|
// :6:25: error: comptime control flow inside runtime block
|
||||||
// :5:18: note: runtime control flow here
|
// :6:18: note: runtime control flow here
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var p: anyerror!usize = undefined;
|
var p: anyerror!usize = undefined;
|
||||||
|
_ = &p;
|
||||||
comptime var q = true;
|
comptime var q = true;
|
||||||
outer: inline while (q) {
|
outer: inline while (q) {
|
||||||
while (p) |_| {
|
while (p) |_| {
|
||||||
@ -13,5 +14,5 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :6:13: error: comptime control flow inside runtime block
|
// :7:13: error: comptime control flow inside runtime block
|
||||||
// :5:16: note: runtime control flow here
|
// :6:16: note: runtime control flow here
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var p: ?usize = undefined;
|
var p: ?usize = undefined;
|
||||||
|
_ = &p;
|
||||||
comptime var q = true;
|
comptime var q = true;
|
||||||
outer: inline while (q) {
|
outer: inline while (q) {
|
||||||
while (p) |_| continue :outer;
|
while (p) |_| continue :outer;
|
||||||
@ -11,5 +12,5 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :5:23: error: comptime control flow inside runtime block
|
// :6:23: error: comptime control flow inside runtime block
|
||||||
// :5:16: note: runtime control flow here
|
// :6:16: note: runtime control flow here
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
pub export fn entry() void {
|
pub export fn entry() void {
|
||||||
var a = false;
|
var a = false;
|
||||||
|
_ = &a;
|
||||||
const arr1 = .{ 1, 2, 3 };
|
const arr1 = .{ 1, 2, 3 };
|
||||||
loop: inline for (arr1) |val1| {
|
loop: inline for (arr1) |val1| {
|
||||||
_ = val1;
|
_ = val1;
|
||||||
@ -17,5 +18,5 @@ pub export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :9:30: error: comptime control flow inside runtime block
|
// :10:30: error: comptime control flow inside runtime block
|
||||||
// :6:13: note: runtime control flow here
|
// :7:13: note: runtime control flow here
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var x: u32 = 0;
|
var x: u32 = 0;
|
||||||
|
_ = &x;
|
||||||
for (0..1, 1..2) |_, _| {
|
for (0..1, 1..2) |_, _| {
|
||||||
var y = x + if (x == 0) 1 else 0;
|
var y = x + if (x == 0) 1 else 0;
|
||||||
_ = y;
|
_ = &y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10,5 +11,5 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :4:21: error: value with comptime-only type 'comptime_int' depends on runtime control flow
|
// :5:21: error: value with comptime-only type 'comptime_int' depends on runtime control flow
|
||||||
// :3:10: note: runtime control flow here
|
// :4:10: note: runtime control flow here
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
comptime {
|
comptime {
|
||||||
var a: []u8 = undefined;
|
var a: []u8 = undefined;
|
||||||
var b = a[0..10];
|
var b = a[0..10];
|
||||||
_ = b;
|
_ = &b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -3,7 +3,7 @@ const Foo = struct {
|
|||||||
};
|
};
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var f: Foo = undefined;
|
var f: Foo = undefined;
|
||||||
_ = f;
|
_ = &f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -2,7 +2,7 @@ comptime {
|
|||||||
var a: @Vector(4, u8) = [_]u8{ 1, 2, 255, 4 };
|
var a: @Vector(4, u8) = [_]u8{ 1, 2, 255, 4 };
|
||||||
var b: @Vector(4, u8) = [_]u8{ 5, 6, 1, 8 };
|
var b: @Vector(4, u8) = [_]u8{ 5, 6, 1, 8 };
|
||||||
var x = a + b;
|
var x = a + b;
|
||||||
_ = x;
|
_ = .{ &a, &b, &x };
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
const ContextAllocator = MemoryPool(usize);
|
const ContextAllocator = MemoryPool(usize);
|
||||||
|
|
||||||
pub fn MemoryPool(comptime T: type) type {
|
pub fn MemoryPool(comptime T: type) type {
|
||||||
const free_list_t = @compileError(
|
const free_list_t = @compileError("aoeu");
|
||||||
"aoeu",
|
|
||||||
);
|
|
||||||
_ = T;
|
_ = T;
|
||||||
|
|
||||||
return struct {
|
return struct {
|
||||||
@ -12,7 +10,7 @@ pub fn MemoryPool(comptime T: type) type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var allocator: ContextAllocator = undefined;
|
const allocator: ContextAllocator = undefined;
|
||||||
_ = allocator;
|
_ = allocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
comptime {
|
comptime {
|
||||||
var a: *u8 = undefined;
|
const a: *u8 = undefined;
|
||||||
_ = a.*;
|
_ = a.*;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var a: []u8 = undefined;
|
var a: []u8 = undefined;
|
||||||
_ = a.*.len;
|
_ = a.*.len;
|
||||||
|
_ = &a;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
var s_buffer: [10]u8 = undefined;
|
var s_buffer: [10]u8 = undefined;
|
||||||
pub fn pass(in: []u8) []u8 {
|
pub fn pass(in: []u8) []u8 {
|
||||||
var out = &s_buffer;
|
var out = &s_buffer;
|
||||||
|
_ = &out;
|
||||||
out.*.* = in[0];
|
out.*.* = in[0];
|
||||||
return out.*[0..1];
|
return out.*[0..1];
|
||||||
}
|
}
|
||||||
@ -13,4 +14,4 @@ export fn entry() usize {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :4:10: error: cannot dereference non-pointer type '[10]u8'
|
// :5:10: error: cannot dereference non-pointer type '[10]u8'
|
||||||
|
|||||||
@ -16,7 +16,7 @@ comptime {
|
|||||||
_ = payload_ptr.*;
|
_ = payload_ptr.*;
|
||||||
}
|
}
|
||||||
comptime {
|
comptime {
|
||||||
var val: u8 = 15;
|
const val: u8 = 15;
|
||||||
var err_union: anyerror!u8 = val;
|
var err_union: anyerror!u8 = val;
|
||||||
|
|
||||||
const payload_ptr = &(err_union catch unreachable);
|
const payload_ptr = &(err_union catch unreachable);
|
||||||
|
|||||||
@ -8,11 +8,11 @@ const Bar = union {
|
|||||||
};
|
};
|
||||||
export fn a() void {
|
export fn a() void {
|
||||||
var foo: Foo = undefined;
|
var foo: Foo = undefined;
|
||||||
_ = foo;
|
_ = &foo;
|
||||||
}
|
}
|
||||||
export fn b() void {
|
export fn b() void {
|
||||||
var bar: Bar = undefined;
|
var bar: Bar = undefined;
|
||||||
_ = bar;
|
_ = &bar;
|
||||||
}
|
}
|
||||||
export fn c() void {
|
export fn c() void {
|
||||||
const baz = &@as(O, undefined);
|
const baz = &@as(O, undefined);
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
comptime {
|
comptime {
|
||||||
var a: i64 = undefined;
|
var a: i64 = undefined;
|
||||||
_ = a / a;
|
_ = a / a;
|
||||||
|
_ = &a;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -11,12 +11,13 @@ pub export fn entry2() void {
|
|||||||
fn func(_: ?*anyopaque) void {}
|
fn func(_: ?*anyopaque) void {}
|
||||||
pub export fn entry3() void {
|
pub export fn entry3() void {
|
||||||
var x: *?*usize = undefined;
|
var x: *?*usize = undefined;
|
||||||
|
_ = &x;
|
||||||
const ptr: *const anyopaque = x;
|
const ptr: *const anyopaque = x;
|
||||||
_ = ptr;
|
_ = ptr;
|
||||||
}
|
}
|
||||||
export fn entry4() void {
|
export fn entry4() void {
|
||||||
var a: []*u32 = undefined;
|
var a: []*u32 = undefined;
|
||||||
|
_ = &a;
|
||||||
var b: []anyopaque = undefined;
|
var b: []anyopaque = undefined;
|
||||||
b = a;
|
b = a;
|
||||||
}
|
}
|
||||||
@ -32,5 +33,5 @@ export fn entry4() void {
|
|||||||
// :11:12: note: parameter type declared here
|
// :11:12: note: parameter type declared here
|
||||||
// :15:35: error: expected type '*const anyopaque', found '*?*usize'
|
// :15:35: error: expected type '*const anyopaque', found '*?*usize'
|
||||||
// :15:35: note: cannot implicitly cast double pointer '*?*usize' to anyopaque pointer '*const anyopaque'
|
// :15:35: note: cannot implicitly cast double pointer '*?*usize' to anyopaque pointer '*const anyopaque'
|
||||||
// :21:9: error: expected type '[]anyopaque', found '[]*u32'
|
// :22:9: error: expected type '[]anyopaque', found '[]*u32'
|
||||||
// :21:9: note: cannot implicitly cast double pointer '[]*u32' to anyopaque pointer '[]anyopaque'
|
// :22:9: note: cannot implicitly cast double pointer '[]*u32' to anyopaque pointer '[]anyopaque'
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var x: u32 = 0;
|
const x: u32 = 0;
|
||||||
switch (x) {}
|
switch (x) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
pub export fn entry() void {
|
pub export fn entry() void {
|
||||||
const E = enum(comptime_int) { a, b, c, _ };
|
const E = enum(comptime_int) { a, b, c, _ };
|
||||||
var e: E = .a;
|
var e: E = .a;
|
||||||
_ = e;
|
_ = &e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -3,7 +3,7 @@ pub const Foo = enum(c_int) {
|
|||||||
C = D,
|
C = D,
|
||||||
};
|
};
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var s: Foo = Foo.E;
|
const s: Foo = Foo.E;
|
||||||
_ = s;
|
_ = s;
|
||||||
}
|
}
|
||||||
const D = 1;
|
const D = 1;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ const Foo = enum(u32) {
|
|||||||
B = 11,
|
B = 11,
|
||||||
};
|
};
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var x: Foo = @enumFromInt(0);
|
const x: Foo = @enumFromInt(0);
|
||||||
_ = x;
|
_ = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11,5 +11,5 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :6:18: error: enum 'tmp.Foo' has no tag with value '0'
|
// :6:20: error: enum 'tmp.Foo' has no tag with value '0'
|
||||||
// :1:13: note: enum declared here
|
// :1:13: note: enum declared here
|
||||||
|
|||||||
@ -6,7 +6,7 @@ const MultipleChoice = enum(u32) {
|
|||||||
E = 60,
|
E = 60,
|
||||||
};
|
};
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var x = MultipleChoice.C;
|
const x = MultipleChoice.C;
|
||||||
_ = x;
|
_ = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ pub export fn entry() void {
|
|||||||
e: u8,
|
e: u8,
|
||||||
};
|
};
|
||||||
var a = .{@sizeOf(bitfield)};
|
var a = .{@sizeOf(bitfield)};
|
||||||
_ = a;
|
_ = &a;
|
||||||
}
|
}
|
||||||
|
|
||||||
// error
|
// error
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
comptime {
|
comptime {
|
||||||
const z = i32!i32;
|
const z = i32!i32;
|
||||||
var x: z = undefined;
|
const x: z = undefined;
|
||||||
_ = x;
|
_ = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ const Foo = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var rule_set = try Foo.init();
|
const rule_set = try Foo.init();
|
||||||
_ = rule_set;
|
_ = rule_set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,12 +11,13 @@ fn foo(a: u8, comptime PtrTy: type) S(PtrTy) {
|
|||||||
}
|
}
|
||||||
pub export fn entry() void {
|
pub export fn entry() void {
|
||||||
var a: u8 = 1;
|
var a: u8 = 1;
|
||||||
|
_ = &a;
|
||||||
_ = foo(a, fn () void);
|
_ = foo(a, fn () void);
|
||||||
}
|
}
|
||||||
// error
|
// error
|
||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :14:13: error: unable to resolve comptime value
|
// :15:13: error: unable to resolve comptime value
|
||||||
// :14:13: note: argument to function being called at comptime must be comptime-known
|
// :15:13: note: argument to function being called at comptime must be comptime-known
|
||||||
// :9:38: note: expression is evaluated at comptime because the generic function was instantiated with a comptime-only return type
|
// :9:38: note: expression is evaluated at comptime because the generic function was instantiated with a comptime-only return type
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
const Set1 = error{ A, B };
|
const Set1 = error{ A, B };
|
||||||
const Set2 = error{ A, C };
|
const Set2 = error{ A, C };
|
||||||
comptime {
|
comptime {
|
||||||
var x = Set1.B;
|
const x = Set1.B;
|
||||||
var y: Set2 = @errorCast(x);
|
const y: Set2 = @errorCast(x);
|
||||||
_ = y;
|
_ = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10,4 +10,4 @@ comptime {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :5:19: error: 'error.B' not a member of error set 'error{C,A}'
|
// :5:21: error: 'error.B' not a member of error set 'error{C,A}'
|
||||||
|
|||||||
@ -7,7 +7,7 @@ const Small = enum(u2) {
|
|||||||
|
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var y = @as(f32, 3);
|
var y = @as(f32, 3);
|
||||||
var x: Small = @enumFromInt(y);
|
const x: Small = @enumFromInt((&y).*);
|
||||||
_ = x;
|
_ = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,4 +15,4 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :10:33: error: expected integer type, found 'f32'
|
// :10:39: error: expected integer type, found 'f32'
|
||||||
|
|||||||
@ -2,7 +2,7 @@ const Letter = extern union {
|
|||||||
A,
|
A,
|
||||||
};
|
};
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var a = Letter{ .A = {} };
|
const a: Letter = .{ .A = {} };
|
||||||
_ = a;
|
_ = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const Payload = extern union(Letter) {
|
|||||||
C: bool,
|
C: bool,
|
||||||
};
|
};
|
||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var a = Payload{ .A = 1234 };
|
const a: Payload = .{ .A = 1234 };
|
||||||
_ = a;
|
_ = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
export fn entry() void {
|
export fn entry() void {
|
||||||
var slice: []i32 = undefined;
|
var slice: []i32 = undefined;
|
||||||
|
_ = &slice;
|
||||||
const info = @TypeOf(slice).unknown;
|
const info = @TypeOf(slice).unknown;
|
||||||
_ = info;
|
_ = info;
|
||||||
}
|
}
|
||||||
@ -8,5 +9,5 @@ export fn entry() void {
|
|||||||
// backend=stage2
|
// backend=stage2
|
||||||
// target=native
|
// target=native
|
||||||
//
|
//
|
||||||
// :3:32: error: type '[]i32' has no members
|
// :4:32: error: type '[]i32' has no members
|
||||||
// :3:32: note: slice values have 'len' and 'ptr' members
|
// :4:32: note: slice values have 'len' and 'ptr' members
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user