mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 23:22:44 +00:00
test: fix incorrect default target spec; port all incremental tests
This commit is contained in:
parent
133708d939
commit
97b781955e
@ -178,7 +178,7 @@ const TestManifestConfigDefaults = struct {
|
||||
// getting more and more complete
|
||||
// Linux
|
||||
inline for (&[_][]const u8{ "x86_64", "arm", "aarch64" }) |arch| {
|
||||
defaults = defaults ++ arch ++ "-linux-" ++ ",";
|
||||
defaults = defaults ++ arch ++ "-linux" ++ ",";
|
||||
}
|
||||
// macOS
|
||||
inline for (&[_][]const u8{ "x86_64", "aarch64" }) |arch| {
|
||||
|
@ -0,0 +1,17 @@
|
||||
var array = [_]usize{ 0, 42, 123, 34 };
|
||||
var slice: []const usize = &array;
|
||||
|
||||
pub fn main() void {
|
||||
assert(slice[0] == 0);
|
||||
assert(slice[1] == 42);
|
||||
assert(slice[2] == 123);
|
||||
assert(slice[3] == 34);
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
// target=x86_64-linux,x86_64-macos
|
||||
//
|
13
test/incremental/ambiguous_reference.zig
Normal file
13
test/incremental/ambiguous_reference.zig
Normal file
@ -0,0 +1,13 @@
|
||||
const T = struct {
|
||||
const T = struct {
|
||||
fn f() void {
|
||||
_ = T;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// error
|
||||
//
|
||||
// :4:17: error: ambiguous reference
|
||||
// :2:5: note: declared here
|
||||
// :1:1: note: also declared here
|
9
test/incremental/bad_inferred_variable_type.zig
Normal file
9
test/incremental/bad_inferred_variable_type.zig
Normal file
@ -0,0 +1,9 @@
|
||||
pub fn main() void {
|
||||
var x = null;
|
||||
_ = x;
|
||||
}
|
||||
|
||||
// error
|
||||
// output_mode=Exe
|
||||
//
|
||||
// :2:9: error: variable of type '@TypeOf(null)' must be const or comptime
|
9
test/incremental/break_continue.0.zig
Normal file
9
test/incremental/break_continue.0.zig
Normal file
@ -0,0 +1,9 @@
|
||||
pub fn main() void {
|
||||
while (true) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// run
|
||||
// target=x86_64-linux,x86_64-macos,aarch64-linux,aarch64-macos
|
||||
//
|
8
test/incremental/break_continue.1.zig
Normal file
8
test/incremental/break_continue.1.zig
Normal file
@ -0,0 +1,8 @@
|
||||
pub fn main() void {
|
||||
foo: while (true) {
|
||||
break :foo;
|
||||
}
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
10
test/incremental/break_continue.2.zig
Normal file
10
test/incremental/break_continue.2.zig
Normal file
@ -0,0 +1,10 @@
|
||||
pub fn main() void {
|
||||
var i: u64 = 0;
|
||||
while (true) : (i += 1) {
|
||||
if (i == 4) return;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
10
test/incremental/break_continue.3.zig
Normal file
10
test/incremental/break_continue.3.zig
Normal file
@ -0,0 +1,10 @@
|
||||
pub fn main() void {
|
||||
var i: u64 = 0;
|
||||
foo: while (true) : (i += 1) {
|
||||
if (i == 4) return;
|
||||
continue :foo;
|
||||
}
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
11
test/incremental/catch_at_comptime.0.zig
Normal file
11
test/incremental/catch_at_comptime.0.zig
Normal file
@ -0,0 +1,11 @@
|
||||
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
|
||||
//
|
11
test/incremental/catch_at_comptime.1.zig
Normal file
11
test/incremental/catch_at_comptime.1.zig
Normal file
@ -0,0 +1,11 @@
|
||||
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
|
||||
//
|
11
test/incremental/catch_at_comptime.2.zig
Normal file
11
test/incremental/catch_at_comptime.2.zig
Normal file
@ -0,0 +1,11 @@
|
||||
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
|
||||
//
|
10
test/incremental/catch_at_comptime.3.zig
Normal file
10
test/incremental/catch_at_comptime.3.zig
Normal file
@ -0,0 +1,10 @@
|
||||
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
|
||||
//
|
10
test/incremental/catch_at_comptime.4.zig
Normal file
10
test/incremental/catch_at_comptime.4.zig
Normal file
@ -0,0 +1,10 @@
|
||||
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
|
||||
//
|
7
test/incremental/compile_error.zig
Normal file
7
test/incremental/compile_error.zig
Normal file
@ -0,0 +1,7 @@
|
||||
export fn foo() void {
|
||||
@compileError("this is an error");
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:5: error: this is an error
|
16
test/incremental/compile_error_in_inline_fn_call_fixed.0.zig
Normal file
16
test/incremental/compile_error_in_inline_fn_call_fixed.0.zig
Normal file
@ -0,0 +1,16 @@
|
||||
pub fn main() void {
|
||||
var x: usize = 3;
|
||||
const y = add(10, 2, x);
|
||||
if (y - 6 != 0) unreachable;
|
||||
}
|
||||
|
||||
inline fn add(a: usize, b: usize, c: usize) usize {
|
||||
if (a == 10) @compileError("bad");
|
||||
return a + b + c;
|
||||
}
|
||||
|
||||
// error
|
||||
// output_mode=Exe
|
||||
//
|
||||
// :8:18: error: bad
|
||||
// :3:18: note: called from here
|
13
test/incremental/compile_error_in_inline_fn_call_fixed.1.zig
Normal file
13
test/incremental/compile_error_in_inline_fn_call_fixed.1.zig
Normal file
@ -0,0 +1,13 @@
|
||||
pub fn main() void {
|
||||
var x: usize = 3;
|
||||
const y = add(1, 2, x);
|
||||
if (y - 6 != 0) unreachable;
|
||||
}
|
||||
|
||||
inline fn add(a: usize, b: usize, c: usize) usize {
|
||||
if (a == 10) @compileError("bad");
|
||||
return a + b + c;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
17
test/incremental/compile_log.0.zig
Normal file
17
test/incremental/compile_log.0.zig
Normal file
@ -0,0 +1,17 @@
|
||||
export fn _start() noreturn {
|
||||
const b = true;
|
||||
var f: u32 = 1;
|
||||
@compileLog(b, 20, f, x);
|
||||
@compileLog(1000);
|
||||
var bruh: usize = true;
|
||||
_ = bruh;
|
||||
unreachable;
|
||||
}
|
||||
export fn other() void {
|
||||
@compileLog(1234);
|
||||
}
|
||||
fn x() void {}
|
||||
|
||||
// error
|
||||
//
|
||||
// :6:23: error: expected usize, found bool
|
16
test/incremental/compile_log.1.zig
Normal file
16
test/incremental/compile_log.1.zig
Normal file
@ -0,0 +1,16 @@
|
||||
export fn _start() noreturn {
|
||||
const b = true;
|
||||
var f: u32 = 1;
|
||||
@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
|
12
test/incremental/comptime_var.0.zig
Normal file
12
test/incremental/comptime_var.0.zig
Normal file
@ -0,0 +1,12 @@
|
||||
pub fn main() void {
|
||||
var a: u32 = 0;
|
||||
comptime var b: u32 = 0;
|
||||
if (a == 0) b = 3;
|
||||
}
|
||||
|
||||
// error
|
||||
// output_mode=Exe
|
||||
// target=x86_64-linux,x86_64-macos
|
||||
//
|
||||
// :4:21: error: store to comptime variable depends on runtime condition
|
||||
// :4:11: note: runtime condition here
|
13
test/incremental/comptime_var.1.zig
Normal file
13
test/incremental/comptime_var.1.zig
Normal file
@ -0,0 +1,13 @@
|
||||
pub fn main() void {
|
||||
var a: u32 = 0;
|
||||
comptime var b: u32 = 0;
|
||||
switch (a) {
|
||||
0 => {},
|
||||
else => b = 3,
|
||||
}
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :6:21: error: store to comptime variable depends on runtime condition
|
||||
// :4:13: note: runtime condition here
|
34
test/incremental/comptime_var.2.zig
Normal file
34
test/incremental/comptime_var.2.zig
Normal file
@ -0,0 +1,34 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
extern "c" fn write(usize, usize, usize) usize;
|
||||
|
||||
pub fn main() void {
|
||||
comptime var len: u32 = 5;
|
||||
print(len);
|
||||
len += 9;
|
||||
print(len);
|
||||
}
|
||||
|
||||
fn print(len: usize) void {
|
||||
switch (builtin.os.tag) {
|
||||
.linux => {
|
||||
asm volatile ("syscall"
|
||||
:
|
||||
: [number] "{rax}" (1),
|
||||
[arg1] "{rdi}" (1),
|
||||
[arg2] "{rsi}" (@ptrToInt("Hello, World!\n")),
|
||||
[arg3] "{rdx}" (len),
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
},
|
||||
.macos => {
|
||||
_ = write(1, @ptrToInt("Hello, World!\n"), len);
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
||||
// HelloHello, World!
|
||||
//
|
10
test/incremental/comptime_var.3.zig
Normal file
10
test/incremental/comptime_var.3.zig
Normal file
@ -0,0 +1,10 @@
|
||||
comptime {
|
||||
var x: i32 = 1;
|
||||
x += 1;
|
||||
if (x != 1) unreachable;
|
||||
}
|
||||
pub fn main() void {}
|
||||
|
||||
// error
|
||||
//
|
||||
// :4:17: error: unable to resolve comptime value
|
9
test/incremental/comptime_var.4.zig
Normal file
9
test/incremental/comptime_var.4.zig
Normal file
@ -0,0 +1,9 @@
|
||||
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
|
15
test/incremental/comptime_var.5.zig
Normal file
15
test/incremental/comptime_var.5.zig
Normal file
@ -0,0 +1,15 @@
|
||||
pub fn main() void {
|
||||
var a: u32 = 0;
|
||||
if (a == 0) {
|
||||
comptime var b: u32 = 0;
|
||||
b = 1;
|
||||
}
|
||||
}
|
||||
comptime {
|
||||
var x: i32 = 1;
|
||||
x += 1;
|
||||
if (x != 2) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
32
test/incremental/comptime_var.6.zig
Normal file
32
test/incremental/comptime_var.6.zig
Normal file
@ -0,0 +1,32 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
extern "c" fn write(usize, 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 {
|
||||
switch (builtin.os.tag) {
|
||||
.linux => {
|
||||
asm volatile ("syscall"
|
||||
:
|
||||
: [number] "{rax}" (1),
|
||||
[arg1] "{rdi}" (1),
|
||||
[arg2] "{rsi}" (@ptrToInt("Hello")),
|
||||
[arg3] "{rdx}" (len),
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
},
|
||||
.macos => {
|
||||
_ = write(1, @ptrToInt("Hello"), len);
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
||||
// HeHelHellHello
|
6
test/incremental/double_ampersand.0.zig
Normal file
6
test/incremental/double_ampersand.0.zig
Normal file
@ -0,0 +1,6 @@
|
||||
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
|
11
test/incremental/double_ampersand.1.zig
Normal file
11
test/incremental/double_ampersand.1.zig
Normal file
@ -0,0 +1,11 @@
|
||||
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
|
7
test/incremental/double_ampersand.2.zig
Normal file
7
test/incremental/double_ampersand.2.zig
Normal file
@ -0,0 +1,7 @@
|
||||
pub fn main() void {
|
||||
const b: u8 = 1;
|
||||
_ = &&b;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
9
test/incremental/extern_variable_has_no_type.0.zig
Normal file
9
test/incremental/extern_variable_has_no_type.0.zig
Normal file
@ -0,0 +1,9 @@
|
||||
comptime {
|
||||
const x = foo + foo;
|
||||
_ = x;
|
||||
}
|
||||
extern var foo: i32;
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:15: error: unable to resolve comptime value
|
8
test/incremental/extern_variable_has_no_type.1.zig
Normal file
8
test/incremental/extern_variable_has_no_type.1.zig
Normal file
@ -0,0 +1,8 @@
|
||||
export fn entry() void {
|
||||
_ = foo;
|
||||
}
|
||||
extern var foo;
|
||||
|
||||
// error
|
||||
//
|
||||
// :4:8: error: unable to infer variable type
|
14
test/incremental/function_redeclaration.zig
Normal file
14
test/incremental/function_redeclaration.zig
Normal file
@ -0,0 +1,14 @@
|
||||
// dummy comment
|
||||
fn entry() void {}
|
||||
fn entry() void {}
|
||||
|
||||
fn foo() void {
|
||||
var foo = 1234;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:1: error: redeclaration of 'entry'
|
||||
// :2:1: note: other declaration here
|
||||
// :6:9: error: local shadows declaration of 'foo'
|
||||
// :5:1: note: declared here
|
8
test/incremental/global_variable_redeclaration.zig
Normal file
8
test/incremental/global_variable_redeclaration.zig
Normal file
@ -0,0 +1,8 @@
|
||||
// dummy comment
|
||||
var foo = false;
|
||||
var foo = true;
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:1: error: redeclaration of 'foo'
|
||||
// :2:1: note: other declaration here
|
@ -0,0 +1,5 @@
|
||||
// error
|
||||
// output_mode=Exe
|
||||
// target=x86_64-linux
|
||||
//
|
||||
// :109:9: error: struct 'tmp.tmp' has no member named 'main'
|
@ -0,0 +1,5 @@
|
||||
pub export fn _start() noreturn {}
|
||||
|
||||
// error
|
||||
//
|
||||
// :1:34: error: expected noreturn, found void
|
32
test/incremental/hello_world_with_updates_x86_64_linux.2.zig
Normal file
32
test/incremental/hello_world_with_updates_x86_64_linux.2.zig
Normal file
@ -0,0 +1,32 @@
|
||||
pub export fn _start() noreturn {
|
||||
print();
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
fn print() void {
|
||||
asm volatile ("syscall"
|
||||
:
|
||||
: [number] "{rax}" (1),
|
||||
[arg1] "{rdi}" (1),
|
||||
[arg2] "{rsi}" (@ptrToInt("Hello, World!\n")),
|
||||
[arg3] "{rdx}" (14),
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
fn exit() noreturn {
|
||||
asm volatile ("syscall"
|
||||
:
|
||||
: [number] "{rax}" (231),
|
||||
[arg1] "{rdi}" (0),
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
||||
// Hello, World!
|
||||
//
|
20
test/incremental/hello_world_with_updates_x86_64_linux.3.zig
Normal file
20
test/incremental/hello_world_with_updates_x86_64_linux.3.zig
Normal file
@ -0,0 +1,20 @@
|
||||
pub fn main() void {
|
||||
print();
|
||||
}
|
||||
|
||||
fn print() void {
|
||||
asm volatile ("syscall"
|
||||
:
|
||||
: [number] "{rax}" (1),
|
||||
[arg1] "{rdi}" (1),
|
||||
[arg2] "{rsi}" (@ptrToInt("Hello, World!\n")),
|
||||
[arg3] "{rdx}" (14),
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
||||
// Hello, World!
|
||||
//
|
20
test/incremental/hello_world_with_updates_x86_64_linux.4.zig
Normal file
20
test/incremental/hello_world_with_updates_x86_64_linux.4.zig
Normal file
@ -0,0 +1,20 @@
|
||||
pub fn main() void {
|
||||
print();
|
||||
}
|
||||
|
||||
fn print() void {
|
||||
asm volatile ("syscall"
|
||||
:
|
||||
: [number] "{rax}" (1),
|
||||
[arg1] "{rdi}" (1),
|
||||
[arg2] "{rsi}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")),
|
||||
[arg3] "{rdx}" (104),
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
||||
// What is up? This is a longer message that will force the data to be relocated in virtual address space.
|
||||
//
|
22
test/incremental/hello_world_with_updates_x86_64_linux.5.zig
Normal file
22
test/incremental/hello_world_with_updates_x86_64_linux.5.zig
Normal file
@ -0,0 +1,22 @@
|
||||
pub fn main() void {
|
||||
print();
|
||||
print();
|
||||
}
|
||||
|
||||
fn print() void {
|
||||
asm volatile ("syscall"
|
||||
:
|
||||
: [number] "{rax}" (1),
|
||||
[arg1] "{rdi}" (1),
|
||||
[arg2] "{rsi}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")),
|
||||
[arg3] "{rdx}" (104),
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
||||
// What is up? This is a longer message that will force the data to be relocated in virtual address space.
|
||||
// What is up? This is a longer message that will force the data to be relocated in virtual address space.
|
||||
//
|
@ -0,0 +1,5 @@
|
||||
// error
|
||||
// output_mode=Exe
|
||||
// target=x86_64-macos
|
||||
//
|
||||
// :109:9: error: struct 'tmp.tmp' has no member named 'main'
|
@ -0,0 +1,5 @@
|
||||
pub export fn main() noreturn {}
|
||||
|
||||
// error
|
||||
//
|
||||
// :1:32: error: expected noreturn, found void
|
19
test/incremental/hello_world_with_updates_x86_64_macos.2.zig
Normal file
19
test/incremental/hello_world_with_updates_x86_64_macos.2.zig
Normal file
@ -0,0 +1,19 @@
|
||||
extern "c" fn write(usize, usize, usize) usize;
|
||||
extern "c" fn exit(usize) noreturn;
|
||||
|
||||
pub export fn main() noreturn {
|
||||
print();
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
fn print() void {
|
||||
const msg = @ptrToInt("Hello, World!\n");
|
||||
const len = 14;
|
||||
_ = write(1, msg, len);
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
||||
// Hello, World!
|
||||
//
|
16
test/incremental/hello_world_with_updates_x86_64_macos.3.zig
Normal file
16
test/incremental/hello_world_with_updates_x86_64_macos.3.zig
Normal file
@ -0,0 +1,16 @@
|
||||
extern "c" fn write(usize, usize, usize) usize;
|
||||
|
||||
pub fn main() void {
|
||||
print();
|
||||
}
|
||||
|
||||
fn print() void {
|
||||
const msg = @ptrToInt("Hello, World!\n");
|
||||
const len = 14;
|
||||
_ = write(1, msg, len);
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
||||
// Hello, World!
|
||||
//
|
22
test/incremental/hello_world_with_updates_x86_64_macos.4.zig
Normal file
22
test/incremental/hello_world_with_updates_x86_64_macos.4.zig
Normal file
@ -0,0 +1,22 @@
|
||||
extern "c" fn write(usize, usize, usize) usize;
|
||||
|
||||
pub fn main() void {
|
||||
print();
|
||||
print();
|
||||
print();
|
||||
print();
|
||||
}
|
||||
|
||||
fn print() void {
|
||||
const msg = @ptrToInt("Hello, World!\n");
|
||||
const len = 14;
|
||||
_ = write(1, msg, len);
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
||||
// Hello, World!
|
||||
// Hello, World!
|
||||
// Hello, World!
|
||||
// Hello, World!
|
||||
//
|
16
test/incremental/hello_world_with_updates_x86_64_macos.5.zig
Normal file
16
test/incremental/hello_world_with_updates_x86_64_macos.5.zig
Normal file
@ -0,0 +1,16 @@
|
||||
extern "c" fn write(usize, usize, usize) usize;
|
||||
|
||||
pub fn main() void {
|
||||
print();
|
||||
}
|
||||
|
||||
fn print() void {
|
||||
const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
|
||||
const len = 104;
|
||||
_ = write(1, msg, len);
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
||||
// What is up? This is a longer message that will force the data to be relocated in virtual address space.
|
||||
//
|
18
test/incremental/hello_world_with_updates_x86_64_macos.6.zig
Normal file
18
test/incremental/hello_world_with_updates_x86_64_macos.6.zig
Normal file
@ -0,0 +1,18 @@
|
||||
extern "c" fn write(usize, usize, usize) usize;
|
||||
|
||||
pub fn main() void {
|
||||
print();
|
||||
print();
|
||||
}
|
||||
|
||||
fn print() void {
|
||||
const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
|
||||
const len = 104;
|
||||
_ = write(1, msg, len);
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
||||
// What is up? This is a longer message that will force the data to be relocated in virtual address space.
|
||||
// What is up? This is a longer message that will force the data to be relocated in virtual address space.
|
||||
//
|
16
test/incremental/inline_assembly_x86_64_linux.0.zig
Normal file
16
test/incremental/inline_assembly_x86_64_linux.0.zig
Normal file
@ -0,0 +1,16 @@
|
||||
pub fn main() void {
|
||||
const number = 1234;
|
||||
const x = asm volatile ("syscall"
|
||||
: [o] "{rax}" (-> number),
|
||||
: [number] "{rax}" (231),
|
||||
[arg1] "{rdi}" (60),
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
_ = x;
|
||||
}
|
||||
|
||||
// error
|
||||
// output_mode=Exe
|
||||
// target=x86_64-linux
|
||||
//
|
||||
// :4:27: error: expected type, found comptime_int
|
15
test/incremental/inline_assembly_x86_64_linux.1.zig
Normal file
15
test/incremental/inline_assembly_x86_64_linux.1.zig
Normal file
@ -0,0 +1,15 @@
|
||||
const S = struct {
|
||||
comptime {
|
||||
asm volatile (
|
||||
\\zig_moment:
|
||||
\\syscall
|
||||
);
|
||||
}
|
||||
};
|
||||
pub fn main() void {
|
||||
_ = S;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:13: error: volatile is meaningless on global assembly
|
12
test/incremental/inline_assembly_x86_64_linux.2.zig
Normal file
12
test/incremental/inline_assembly_x86_64_linux.2.zig
Normal file
@ -0,0 +1,12 @@
|
||||
pub fn main() void {
|
||||
var bruh: u32 = 1;
|
||||
asm (""
|
||||
:
|
||||
: [bruh] "{rax}" (4)
|
||||
: "memory"
|
||||
);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:5: error: assembly expression with no output must be marked volatile
|
12
test/incremental/inline_assembly_x86_64_linux.3.zig
Normal file
12
test/incremental/inline_assembly_x86_64_linux.3.zig
Normal file
@ -0,0 +1,12 @@
|
||||
pub fn main() void {}
|
||||
comptime {
|
||||
asm (""
|
||||
:
|
||||
: [bruh] "{rax}" (4)
|
||||
: "memory"
|
||||
);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:5: error: global assembly cannot have inputs, outputs, or clobbers
|
15
test/incremental/inner_func_accessing_outer_var.zig
Normal file
15
test/incremental/inner_func_accessing_outer_var.zig
Normal file
@ -0,0 +1,15 @@
|
||||
pub fn f() void {
|
||||
var bar: bool = true;
|
||||
const S = struct {
|
||||
fn baz() bool {
|
||||
return bar;
|
||||
}
|
||||
};
|
||||
_ = S;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :5:20: error: mutable 'bar' not accessible from here
|
||||
// :2:9: note: declared mutable here
|
||||
// :3:15: note: crosses namespace boundary here
|
8
test/incremental/int_to_ptr.0.zig
Normal file
8
test/incremental/int_to_ptr.0.zig
Normal file
@ -0,0 +1,8 @@
|
||||
pub fn main() void {
|
||||
_ = @intToPtr(*u8, 0);
|
||||
}
|
||||
|
||||
// error
|
||||
// output_mode=Exe
|
||||
//
|
||||
// :2:24: error: pointer type '*u8' does not allow address zero
|
7
test/incremental/int_to_ptr.1.zig
Normal file
7
test/incremental/int_to_ptr.1.zig
Normal file
@ -0,0 +1,7 @@
|
||||
pub fn main() void {
|
||||
_ = @intToPtr(*u32, 2);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:25: error: pointer type '*u32' requires aligned address
|
@ -0,0 +1,31 @@
|
||||
pub fn main() void {
|
||||
const fd = open();
|
||||
_ = write(fd, "a", 1);
|
||||
_ = close(fd);
|
||||
}
|
||||
|
||||
fn open() usize {
|
||||
return 42;
|
||||
}
|
||||
|
||||
fn write(fd: usize, a: [*]const u8, len: usize) usize {
|
||||
return syscall4(.WRITE, fd, @ptrToInt(a), len);
|
||||
}
|
||||
|
||||
fn syscall4(n: enum { WRITE }, a: usize, b: usize, c: usize) usize {
|
||||
_ = n;
|
||||
_ = a;
|
||||
_ = b;
|
||||
_ = c;
|
||||
return 23;
|
||||
}
|
||||
|
||||
fn close(fd: usize) usize {
|
||||
if (fd != 42)
|
||||
unreachable;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// run
|
||||
// target=x86_64-linux
|
||||
//
|
@ -0,0 +1,18 @@
|
||||
pub fn main() void {
|
||||
var x: usize = 1;
|
||||
var y: bool = getFalse();
|
||||
_ = y;
|
||||
|
||||
assert(x == 1);
|
||||
}
|
||||
|
||||
fn getFalse() bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
16
test/incremental/load_store_via_pointer_deref.0.zig
Normal file
16
test/incremental/load_store_via_pointer_deref.0.zig
Normal file
@ -0,0 +1,16 @@
|
||||
pub fn main() void {
|
||||
var x: u32 = undefined;
|
||||
set(&x);
|
||||
assert(x == 123);
|
||||
}
|
||||
|
||||
fn set(x: *u32) void {
|
||||
x.* = 123;
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
16
test/incremental/load_store_via_pointer_deref.1.zig
Normal file
16
test/incremental/load_store_via_pointer_deref.1.zig
Normal file
@ -0,0 +1,16 @@
|
||||
pub fn main() void {
|
||||
var x: u16 = undefined;
|
||||
set(&x);
|
||||
assert(x == 123);
|
||||
}
|
||||
|
||||
fn set(x: *u16) void {
|
||||
x.* = 123;
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
16
test/incremental/load_store_via_pointer_deref.2.zig
Normal file
16
test/incremental/load_store_via_pointer_deref.2.zig
Normal file
@ -0,0 +1,16 @@
|
||||
pub fn main() void {
|
||||
var x: u8 = undefined;
|
||||
set(&x);
|
||||
assert(x == 123);
|
||||
}
|
||||
|
||||
fn set(x: *u8) void {
|
||||
x.* = 123;
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
25
test/incremental/lower_unnamed_consts_structs.0.zig
Normal file
25
test/incremental/lower_unnamed_consts_structs.0.zig
Normal file
@ -0,0 +1,25 @@
|
||||
const Foo = struct {
|
||||
a: u8,
|
||||
b: u32,
|
||||
|
||||
fn first(self: *Foo) u8 {
|
||||
return self.a;
|
||||
}
|
||||
|
||||
fn second(self: *Foo) u32 {
|
||||
return self.b;
|
||||
}
|
||||
};
|
||||
|
||||
pub fn main() void {
|
||||
var foo = Foo{ .a = 1, .b = 5 };
|
||||
assert(foo.first() == 1);
|
||||
assert(foo.second() == 5);
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
35
test/incremental/lower_unnamed_consts_structs.1.zig
Normal file
35
test/incremental/lower_unnamed_consts_structs.1.zig
Normal file
@ -0,0 +1,35 @@
|
||||
const Foo = struct {
|
||||
a: u8,
|
||||
b: u32,
|
||||
|
||||
fn first(self: *Foo) u8 {
|
||||
return self.a;
|
||||
}
|
||||
|
||||
fn second(self: *Foo) u32 {
|
||||
return self.b;
|
||||
}
|
||||
};
|
||||
|
||||
pub fn main() void {
|
||||
var foo = Foo{ .a = 1, .b = 5 };
|
||||
assert(foo.first() == 1);
|
||||
assert(foo.second() == 5);
|
||||
|
||||
foo.a = 10;
|
||||
foo.b = 255;
|
||||
|
||||
assert(foo.first() == 10);
|
||||
assert(foo.second() == 255);
|
||||
|
||||
var foo2 = Foo{ .a = 15, .b = 255 };
|
||||
assert(foo2.first() == 15);
|
||||
assert(foo2.second() == 255);
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
25
test/incremental/lower_unnamed_consts_structs.2.zig
Normal file
25
test/incremental/lower_unnamed_consts_structs.2.zig
Normal file
@ -0,0 +1,25 @@
|
||||
const Foo = struct {
|
||||
a: u8,
|
||||
b: u32,
|
||||
|
||||
fn first(self: *Foo) u8 {
|
||||
return self.a;
|
||||
}
|
||||
|
||||
fn second(self: *Foo) u32 {
|
||||
return self.b;
|
||||
}
|
||||
};
|
||||
|
||||
pub fn main() void {
|
||||
var foo2 = Foo{ .a = 15, .b = 255 };
|
||||
assert(foo2.first() == 15);
|
||||
assert(foo2.second() == 255);
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
18
test/incremental/merge_error_sets.0.zig
Normal file
18
test/incremental/merge_error_sets.0.zig
Normal file
@ -0,0 +1,18 @@
|
||||
pub fn main() void {
|
||||
const E = error{ A, B, D } || error{ A, B, C };
|
||||
E.A catch {};
|
||||
E.B catch {};
|
||||
E.C catch {};
|
||||
E.D catch {};
|
||||
const E2 = error{ X, Y } || @TypeOf(error.Z);
|
||||
E2.X catch {};
|
||||
E2.Y catch {};
|
||||
E2.Z catch {};
|
||||
assert(anyerror || error{Z} == anyerror);
|
||||
}
|
||||
fn assert(b: bool) void {
|
||||
if (!b) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
9
test/incremental/merge_error_sets.1.zig
Normal file
9
test/incremental/merge_error_sets.1.zig
Normal file
@ -0,0 +1,9 @@
|
||||
pub fn main() void {
|
||||
const z = true || false;
|
||||
_ = z;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:15: error: expected error set type, found 'bool'
|
||||
// :2:20: note: '||' merges error sets; 'or' performs boolean OR
|
@ -0,0 +1,13 @@
|
||||
pub export fn _start() noreturn {
|
||||
asm volatile ("syscall"
|
||||
:
|
||||
: [number] "{rax}" (60), // exit
|
||||
[arg1] "{rdi}" (0),
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
// target=x86_64-linux
|
||||
//
|
@ -0,0 +1,12 @@
|
||||
pub export fn _start() noreturn {
|
||||
asm volatile ("syscall"
|
||||
:
|
||||
: [number] "{rax}" (231), // exit_group
|
||||
[arg1] "{rdi}" (0),
|
||||
: "rcx", "r11", "memory"
|
||||
);
|
||||
unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
19
test/incremental/optional_payload.0.zig
Normal file
19
test/incremental/optional_payload.0.zig
Normal file
@ -0,0 +1,19 @@
|
||||
pub fn main() void {
|
||||
var x: u32 = undefined;
|
||||
const maybe_x = byPtr(&x);
|
||||
assert(maybe_x != null);
|
||||
maybe_x.?.* = 123;
|
||||
assert(x == 123);
|
||||
}
|
||||
|
||||
fn byPtr(x: *u32) ?*u32 {
|
||||
return x;
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
// target=x86_64-linux,x86_64-macos
|
||||
//
|
17
test/incremental/optional_payload.1.zig
Normal file
17
test/incremental/optional_payload.1.zig
Normal file
@ -0,0 +1,17 @@
|
||||
pub fn main() void {
|
||||
var x: u32 = undefined;
|
||||
const maybe_x = byPtr(&x);
|
||||
assert(maybe_x == null);
|
||||
}
|
||||
|
||||
fn byPtr(x: *u32) ?*u32 {
|
||||
_ = x;
|
||||
return null;
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
18
test/incremental/optional_payload.2.zig
Normal file
18
test/incremental/optional_payload.2.zig
Normal file
@ -0,0 +1,18 @@
|
||||
pub fn main() void {
|
||||
var x: u8 = undefined;
|
||||
const maybe_x = byPtr(&x);
|
||||
assert(maybe_x != null);
|
||||
maybe_x.?.* = 255;
|
||||
assert(x == 255);
|
||||
}
|
||||
|
||||
fn byPtr(x: *u8) ?*u8 {
|
||||
return x;
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
18
test/incremental/optional_payload.3.zig
Normal file
18
test/incremental/optional_payload.3.zig
Normal file
@ -0,0 +1,18 @@
|
||||
pub fn main() void {
|
||||
var x: i8 = undefined;
|
||||
const maybe_x = byPtr(&x);
|
||||
assert(maybe_x != null);
|
||||
maybe_x.?.* = -1;
|
||||
assert(x == -1);
|
||||
}
|
||||
|
||||
fn byPtr(x: *i8) ?*i8 {
|
||||
return x;
|
||||
}
|
||||
|
||||
fn assert(ok: bool) void {
|
||||
if (!ok) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
11
test/incremental/orelse_at_comptime.0.zig
Normal file
11
test/incremental/orelse_at_comptime.0.zig
Normal file
@ -0,0 +1,11 @@
|
||||
pub fn main() void {
|
||||
const i: ?u64 = 0;
|
||||
const result = i orelse 5;
|
||||
assert(result == 0);
|
||||
}
|
||||
fn assert(b: bool) void {
|
||||
if (!b) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
11
test/incremental/orelse_at_comptime.1.zig
Normal file
11
test/incremental/orelse_at_comptime.1.zig
Normal file
@ -0,0 +1,11 @@
|
||||
pub fn main() void {
|
||||
const i: ?u64 = null;
|
||||
const result = i orelse 5;
|
||||
assert(result == 5);
|
||||
}
|
||||
fn assert(b: bool) void {
|
||||
if (!b) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
9
test/incremental/passing_u0_to_function.zig
Normal file
9
test/incremental/passing_u0_to_function.zig
Normal file
@ -0,0 +1,9 @@
|
||||
pub fn main() void {
|
||||
doNothing(0);
|
||||
}
|
||||
fn doNothing(arg: u0) void {
|
||||
_ = arg;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
12
test/incremental/recursive_inline_function.0.zig
Normal file
12
test/incremental/recursive_inline_function.0.zig
Normal file
@ -0,0 +1,12 @@
|
||||
pub fn main() void {
|
||||
const y = fibonacci(7);
|
||||
if (y - 21 != 0) unreachable;
|
||||
}
|
||||
|
||||
inline fn fibonacci(n: usize) usize {
|
||||
if (n <= 2) return n;
|
||||
return fibonacci(n - 2) + fibonacci(n - 1);
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
16
test/incremental/recursive_inline_function.1.zig
Normal file
16
test/incremental/recursive_inline_function.1.zig
Normal file
@ -0,0 +1,16 @@
|
||||
// This additionally tests that the compile error reports the correct source location.
|
||||
// Without storing source locations relative to the owner decl, the compile error
|
||||
// here would be off by 2 bytes (from the "7" -> "999").
|
||||
pub fn main() void {
|
||||
const y = fibonacci(999);
|
||||
if (y - 21 != 0) unreachable;
|
||||
}
|
||||
|
||||
inline fn fibonacci(n: usize) usize {
|
||||
if (n <= 2) return n;
|
||||
return fibonacci(n - 2) + fibonacci(n - 1);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :11:21: error: evaluation exceeded 1000 backwards branches
|
7
test/incremental/redundant_comptime.0.zig
Normal file
7
test/incremental/redundant_comptime.0.zig
Normal file
@ -0,0 +1,7 @@
|
||||
pub fn main() void {
|
||||
var a: comptime u32 = 0;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:12: error: redundant comptime keyword in already comptime scope
|
9
test/incremental/redundant_comptime.1.zig
Normal file
9
test/incremental/redundant_comptime.1.zig
Normal file
@ -0,0 +1,9 @@
|
||||
pub fn main() void {
|
||||
comptime {
|
||||
var a: u32 = comptime 0;
|
||||
}
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:22: error: redundant comptime keyword in already comptime scope
|
16
test/incremental/returns_in_try.zig
Normal file
16
test/incremental/returns_in_try.zig
Normal file
@ -0,0 +1,16 @@
|
||||
pub fn main() !void {
|
||||
try a();
|
||||
try b();
|
||||
}
|
||||
|
||||
pub fn a() !void {
|
||||
defer try b();
|
||||
}
|
||||
pub fn b() !void {
|
||||
defer return a();
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :7:11: error: 'try' not allowed inside defer expression
|
||||
// :10:11: error: cannot return from defer expression
|
16
test/incremental/runtime_bitwise_and.zig
Normal file
16
test/incremental/runtime_bitwise_and.zig
Normal file
@ -0,0 +1,16 @@
|
||||
pub fn main() void {
|
||||
var i: u32 = 10;
|
||||
var j: u32 = 11;
|
||||
assert(i & 1 == 0);
|
||||
assert(j & 1 == 1);
|
||||
var m1: u32 = 0b1111;
|
||||
var m2: u32 = 0b0000;
|
||||
assert(m1 & 0b1010 == 0b1010);
|
||||
assert(m2 & 0b1010 == 0b0000);
|
||||
}
|
||||
fn assert(b: bool) void {
|
||||
if (!b) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
16
test/incremental/runtime_bitwise_or.zig
Normal file
16
test/incremental/runtime_bitwise_or.zig
Normal file
@ -0,0 +1,16 @@
|
||||
pub fn main() void {
|
||||
var i: u32 = 10;
|
||||
var j: u32 = 11;
|
||||
assert(i | 1 == 11);
|
||||
assert(j | 1 == 11);
|
||||
var m1: u32 = 0b1111;
|
||||
var m2: u32 = 0b0000;
|
||||
assert(m1 | 0b1010 == 0b1111);
|
||||
assert(m2 | 0b1010 == 0b1010);
|
||||
}
|
||||
fn assert(b: bool) void {
|
||||
if (!b) unreachable;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
@ -0,0 +1,16 @@
|
||||
pub fn main() void {
|
||||
assert(callMe(2) == 24);
|
||||
}
|
||||
|
||||
fn callMe(a: u8) u8 {
|
||||
var b: u8 = a + 10;
|
||||
const c = 2 * b;
|
||||
return c;
|
||||
}
|
||||
|
||||
pub fn assert(ok: bool) void {
|
||||
if (!ok) unreachable; // assertion failure
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
@ -0,0 +1,16 @@
|
||||
pub fn main() void {
|
||||
assert(callMe(2) == 24);
|
||||
}
|
||||
|
||||
fn callMe(a: u16) u16 {
|
||||
var b: u16 = a + 10;
|
||||
const c = 2 * b;
|
||||
return c;
|
||||
}
|
||||
|
||||
pub fn assert(ok: bool) void {
|
||||
if (!ok) unreachable; // assertion failure
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
@ -0,0 +1,16 @@
|
||||
pub fn main() void {
|
||||
assert(callMe(2) == 24);
|
||||
}
|
||||
|
||||
fn callMe(a: u32) u32 {
|
||||
var b: u32 = a + 10;
|
||||
const c = 2 * b;
|
||||
return c;
|
||||
}
|
||||
|
||||
pub fn assert(ok: bool) void {
|
||||
if (!ok) unreachable; // assertion failure
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
@ -0,0 +1,8 @@
|
||||
export fn entry() i32 {
|
||||
var foo: i32 addrspace(".general") = 1234;
|
||||
return foo;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:28: error: cannot set address space of local variable 'foo'
|
13
test/incremental/try_in_comptime_in_struct_in_test.zig
Normal file
13
test/incremental/try_in_comptime_in_struct_in_test.zig
Normal file
@ -0,0 +1,13 @@
|
||||
test "@unionInit on union w/ tag but no fields" {
|
||||
const S = struct {
|
||||
comptime {
|
||||
try expect(false);
|
||||
}
|
||||
};
|
||||
_ = S;
|
||||
}
|
||||
|
||||
// error
|
||||
// is_test=1
|
||||
//
|
||||
// :4:13: error: 'try' outside function scope
|
13
test/incremental/type_of.0.zig
Normal file
13
test/incremental/type_of.0.zig
Normal file
@ -0,0 +1,13 @@
|
||||
pub fn main() void {
|
||||
var x: usize = 0;
|
||||
_ = x;
|
||||
const z = @TypeOf(x, @as(u128, 5));
|
||||
assert(z == u128);
|
||||
}
|
||||
|
||||
pub fn assert(ok: bool) void {
|
||||
if (!ok) unreachable; // assertion failure
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
11
test/incremental/type_of.1.zig
Normal file
11
test/incremental/type_of.1.zig
Normal file
@ -0,0 +1,11 @@
|
||||
pub fn main() void {
|
||||
const z = @TypeOf(true);
|
||||
assert(z == bool);
|
||||
}
|
||||
|
||||
pub fn assert(ok: bool) void {
|
||||
if (!ok) unreachable; // assertion failure
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
9
test/incremental/type_of.2.zig
Normal file
9
test/incremental/type_of.2.zig
Normal file
@ -0,0 +1,9 @@
|
||||
pub fn main() void {
|
||||
_ = @TypeOf(true, 1);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:9: error: incompatible types: 'bool' and 'comptime_int'
|
||||
// :2:17: note: type 'bool' here
|
||||
// :2:23: note: type 'comptime_int' here
|
8
test/incremental/unused_labels.0.zig
Normal file
8
test/incremental/unused_labels.0.zig
Normal file
@ -0,0 +1,8 @@
|
||||
comptime {
|
||||
foo: {}
|
||||
}
|
||||
|
||||
// error
|
||||
// output_mode=Exe
|
||||
//
|
||||
// :2:5: error: unused block label
|
7
test/incremental/unused_labels.1.zig
Normal file
7
test/incremental/unused_labels.1.zig
Normal file
@ -0,0 +1,7 @@
|
||||
comptime {
|
||||
foo: while (true) {}
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:5: error: unused while loop label
|
7
test/incremental/unused_labels.2.zig
Normal file
7
test/incremental/unused_labels.2.zig
Normal file
@ -0,0 +1,7 @@
|
||||
comptime {
|
||||
foo: for ("foo") |_| {}
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:5: error: unused for loop label
|
8
test/incremental/unused_labels.3.zig
Normal file
8
test/incremental/unused_labels.3.zig
Normal file
@ -0,0 +1,8 @@
|
||||
comptime {
|
||||
blk: {blk: {}}
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :2:11: error: redefinition of label 'blk'
|
||||
// :2:5: note: previous definition here
|
10
test/incremental/unwrap_error_union_simple_errors.0.zig
Normal file
10
test/incremental/unwrap_error_union_simple_errors.0.zig
Normal file
@ -0,0 +1,10 @@
|
||||
pub fn main() void {
|
||||
maybeErr() catch unreachable;
|
||||
}
|
||||
|
||||
fn maybeErr() !void {
|
||||
return;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
11
test/incremental/unwrap_error_union_simple_errors.1.zig
Normal file
11
test/incremental/unwrap_error_union_simple_errors.1.zig
Normal file
@ -0,0 +1,11 @@
|
||||
pub fn main() void {
|
||||
maybeErr() catch return;
|
||||
unreachable;
|
||||
}
|
||||
|
||||
fn maybeErr() !void {
|
||||
return error.NoWay;
|
||||
}
|
||||
|
||||
// run
|
||||
//
|
9
test/incremental/variable_shadowing.0.zig
Normal file
9
test/incremental/variable_shadowing.0.zig
Normal file
@ -0,0 +1,9 @@
|
||||
pub fn main() void {
|
||||
var i: u32 = 10;
|
||||
var i: u32 = 10;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:9: error: redeclaration of local variable 'i'
|
||||
// :2:9: note: previous declaration here
|
9
test/incremental/variable_shadowing.1.zig
Normal file
9
test/incremental/variable_shadowing.1.zig
Normal file
@ -0,0 +1,9 @@
|
||||
var testing: i64 = 10;
|
||||
pub fn main() void {
|
||||
var testing: i64 = 20;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:9: error: local shadows declaration of 'testing'
|
||||
// :1:1: note: declared here
|
13
test/incremental/variable_shadowing.2.zig
Normal file
13
test/incremental/variable_shadowing.2.zig
Normal file
@ -0,0 +1,13 @@
|
||||
fn a() type {
|
||||
return struct {
|
||||
pub fn b() void {
|
||||
const c = 6;
|
||||
const c = 69;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :5:19: error: redeclaration of local constant 'c'
|
||||
// :4:19: note: previous declaration here
|
10
test/incremental/variable_shadowing.3.zig
Normal file
10
test/incremental/variable_shadowing.3.zig
Normal file
@ -0,0 +1,10 @@
|
||||
pub fn main() void {
|
||||
var i = 0;
|
||||
for ("n") |_, i| {
|
||||
}
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:19: error: redeclaration of local variable 'i'
|
||||
// :2:9: note: previous declaration here
|
10
test/incremental/variable_shadowing.4.zig
Normal file
10
test/incremental/variable_shadowing.4.zig
Normal file
@ -0,0 +1,10 @@
|
||||
pub fn main() void {
|
||||
var i = 0;
|
||||
for ("n") |i| {
|
||||
}
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:16: error: redeclaration of local variable 'i'
|
||||
// :2:9: note: previous declaration here
|
10
test/incremental/variable_shadowing.5.zig
Normal file
10
test/incremental/variable_shadowing.5.zig
Normal file
@ -0,0 +1,10 @@
|
||||
pub fn main() void {
|
||||
var i = 0;
|
||||
while ("n") |i| {
|
||||
}
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:18: error: redeclaration of local variable 'i'
|
||||
// :2:9: note: previous declaration here
|
13
test/incremental/variable_shadowing.6.zig
Normal file
13
test/incremental/variable_shadowing.6.zig
Normal file
@ -0,0 +1,13 @@
|
||||
pub fn main() void {
|
||||
var i = 0;
|
||||
while ("n") |bruh| {
|
||||
_ = bruh;
|
||||
} else |i| {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :5:13: error: redeclaration of local variable 'i'
|
||||
// :2:9: note: previous declaration here
|
9
test/incremental/variable_shadowing.7.zig
Normal file
9
test/incremental/variable_shadowing.7.zig
Normal file
@ -0,0 +1,9 @@
|
||||
pub fn main() void {
|
||||
var i = 0;
|
||||
if (true) |i| {}
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :3:16: error: redeclaration of local variable 'i'
|
||||
// :2:9: note: previous declaration here
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user