Commit 97b781955e

Jakub Konka <kubkon@jakubkonka.com>
2022-04-27 15:37:54
test: fix incorrect default target spec; port all incremental tests
1 parent 133708d
Changed files (102)
src
test
incremental
src/test.zig
@@ -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| {
test/incremental/access_slice_element_by_index_slice_elem_val.zig
@@ -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
+//
test/incremental/ambiguous_reference.zig
@@ -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
test/incremental/bad_inferred_variable_type.zig
@@ -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
test/incremental/break_continue.0.zig
@@ -0,0 +1,9 @@
+pub fn main() void {
+    while (true) {
+        break;
+    }
+}
+
+// run
+// target=x86_64-linux,x86_64-macos,aarch64-linux,aarch64-macos
+//
test/incremental/break_continue.1.zig
@@ -0,0 +1,8 @@
+pub fn main() void {
+    foo: while (true) {
+        break :foo;
+    }
+}
+
+// run
+//
test/incremental/break_continue.2.zig
@@ -0,0 +1,10 @@
+pub fn main() void {
+    var i: u64 = 0;
+    while (true) : (i += 1) {
+        if (i == 4) return;
+        continue;
+    }
+}
+
+// run
+//
test/incremental/break_continue.3.zig
@@ -0,0 +1,10 @@
+pub fn main() void {
+    var i: u64 = 0;
+    foo: while (true) : (i += 1) {
+        if (i == 4) return;
+        continue :foo;
+    }
+}
+
+// run
+//
test/incremental/catch_at_comptime.0.zig
@@ -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
+//
test/incremental/catch_at_comptime.1.zig
@@ -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
+//
test/incremental/catch_at_comptime.2.zig
@@ -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
+//
test/incremental/catch_at_comptime.3.zig
@@ -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
+//
test/incremental/catch_at_comptime.4.zig
@@ -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
+//
test/incremental/compile_error.zig
@@ -0,0 +1,7 @@
+export fn foo() void {
+    @compileError("this is an error");
+}
+
+// error
+//
+// :2:5: error: this is an error
test/incremental/compile_error_in_inline_fn_call_fixed.0.zig
@@ -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
test/incremental/compile_error_in_inline_fn_call_fixed.1.zig
@@ -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
+//
test/incremental/compile_log.0.zig
@@ -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
test/incremental/compile_log.1.zig
@@ -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
test/incremental/comptime_var.0.zig
@@ -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
test/incremental/comptime_var.1.zig
@@ -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
test/incremental/comptime_var.2.zig
@@ -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!
+//
test/incremental/comptime_var.3.zig
@@ -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
test/incremental/comptime_var.4.zig
@@ -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
test/incremental/comptime_var.5.zig
@@ -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
+//
test/incremental/comptime_var.6.zig
@@ -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
test/incremental/double_ampersand.0.zig
@@ -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
test/incremental/double_ampersand.1.zig
@@ -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
test/incremental/double_ampersand.2.zig
@@ -0,0 +1,7 @@
+pub fn main() void {
+    const b: u8 = 1;
+    _ = &&b;
+}
+
+// run
+//
test/incremental/extern_variable_has_no_type.0.zig
@@ -0,0 +1,9 @@
+comptime {
+    const x = foo + foo;
+    _ = x;
+}
+extern var foo: i32;
+
+// error
+//
+// :2:15: error: unable to resolve comptime value
test/incremental/extern_variable_has_no_type.1.zig
@@ -0,0 +1,8 @@
+export fn entry() void {
+    _ = foo;
+}
+extern var foo;
+
+// error
+//
+// :4:8: error: unable to infer variable type
test/incremental/function_redeclaration.zig
@@ -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
test/incremental/global_variable_redeclaration.zig
@@ -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
test/incremental/hello_world_with_updates_x86_64_linux.0.zig
@@ -0,0 +1,5 @@
+// error
+// output_mode=Exe
+// target=x86_64-linux
+//
+// :109:9: error: struct 'tmp.tmp' has no member named 'main'
test/incremental/hello_world_with_updates_x86_64_linux.1.zig
@@ -0,0 +1,5 @@
+pub export fn _start() noreturn {}
+
+// error
+//
+// :1:34: error: expected noreturn, found void
test/incremental/hello_world_with_updates_x86_64_linux.2.zig
@@ -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!
+//
test/incremental/hello_world_with_updates_x86_64_linux.3.zig
@@ -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!
+//
test/incremental/hello_world_with_updates_x86_64_linux.4.zig
@@ -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.
+//
test/incremental/hello_world_with_updates_x86_64_linux.5.zig
@@ -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.
+//
test/incremental/hello_world_with_updates_x86_64_macos.0.zig
@@ -0,0 +1,5 @@
+// error
+// output_mode=Exe
+// target=x86_64-macos
+//
+// :109:9: error: struct 'tmp.tmp' has no member named 'main'
test/incremental/hello_world_with_updates_x86_64_macos.1.zig
@@ -0,0 +1,5 @@
+pub export fn main() noreturn {}
+
+// error
+//
+// :1:32: error: expected noreturn, found void
test/incremental/hello_world_with_updates_x86_64_macos.2.zig
@@ -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!
+//
test/incremental/hello_world_with_updates_x86_64_macos.3.zig
@@ -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!
+//
test/incremental/hello_world_with_updates_x86_64_macos.4.zig
@@ -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!
+//
test/incremental/hello_world_with_updates_x86_64_macos.5.zig
@@ -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.
+//
test/incremental/hello_world_with_updates_x86_64_macos.6.zig
@@ -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.
+//
test/incremental/inline_assembly_x86_64_linux.0.zig
@@ -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
test/incremental/inline_assembly_x86_64_linux.1.zig
@@ -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
test/incremental/inline_assembly_x86_64_linux.2.zig
@@ -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
test/incremental/inline_assembly_x86_64_linux.3.zig
@@ -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
test/incremental/inner_func_accessing_outer_var.zig
@@ -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
test/incremental/int_to_ptr.0.zig
@@ -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
test/incremental/int_to_ptr.1.zig
@@ -0,0 +1,7 @@
+pub fn main() void {
+    _ = @intToPtr(*u32, 2);
+}
+
+// error
+//
+// :2:25: error: pointer type '*u32' requires aligned address
test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig
@@ -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
+//
test/incremental/issue_7187_miscompilation_with_bool_return_type.zig
@@ -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
+//
test/incremental/load_store_via_pointer_deref.0.zig
@@ -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
+//
test/incremental/load_store_via_pointer_deref.1.zig
@@ -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
+//
test/incremental/load_store_via_pointer_deref.2.zig
@@ -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
+//
test/incremental/lower_unnamed_consts_structs.0.zig
@@ -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
+//
test/incremental/lower_unnamed_consts_structs.1.zig
@@ -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
+//
test/incremental/lower_unnamed_consts_structs.2.zig
@@ -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
+//
test/incremental/merge_error_sets.0.zig
@@ -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
+//
test/incremental/merge_error_sets.1.zig
@@ -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
test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig
@@ -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
+//
test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig
@@ -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
+//
test/incremental/optional_payload.0.zig
@@ -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
+//
test/incremental/optional_payload.1.zig
@@ -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
+//
test/incremental/optional_payload.2.zig
@@ -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
+//
test/incremental/optional_payload.3.zig
@@ -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
+//
test/incremental/orelse_at_comptime.0.zig
@@ -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
+//
test/incremental/orelse_at_comptime.1.zig
@@ -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
+//
test/incremental/passing_u0_to_function.zig
@@ -0,0 +1,9 @@
+pub fn main() void {
+    doNothing(0);
+}
+fn doNothing(arg: u0) void {
+    _ = arg;
+}
+
+// run
+//
test/incremental/recursive_inline_function.0.zig
@@ -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
+//
test/incremental/recursive_inline_function.1.zig
@@ -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
test/incremental/redundant_comptime.0.zig
@@ -0,0 +1,7 @@
+pub fn main() void {
+    var a: comptime u32 = 0;
+}
+
+// error
+//
+// :2:12: error: redundant comptime keyword in already comptime scope
test/incremental/redundant_comptime.1.zig
@@ -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
test/incremental/returns_in_try.zig
@@ -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
test/incremental/runtime_bitwise_and.zig
@@ -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
+//
test/incremental/runtime_bitwise_or.zig
@@ -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
+//
test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig
@@ -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
+//
test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig
@@ -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
+//
test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig
@@ -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
+//
test/incremental/setting_an_address_space_on_a_local_variable.zig
@@ -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'
test/incremental/try_in_comptime_in_struct_in_test.zig
@@ -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
test/incremental/type_of.0.zig
@@ -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
+//
test/incremental/type_of.1.zig
@@ -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
+//
test/incremental/type_of.2.zig
@@ -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
test/incremental/unused_labels.0.zig
@@ -0,0 +1,8 @@
+comptime {
+    foo: {}
+}
+
+// error
+// output_mode=Exe
+//
+// :2:5: error: unused block label
test/incremental/unused_labels.1.zig
@@ -0,0 +1,7 @@
+comptime {
+    foo: while (true) {}
+}
+
+// error
+//
+// :2:5: error: unused while loop label
test/incremental/unused_labels.2.zig
@@ -0,0 +1,7 @@
+comptime {
+    foo: for ("foo") |_| {}
+}
+
+// error
+//
+// :2:5: error: unused for loop label
test/incremental/unused_labels.3.zig
@@ -0,0 +1,8 @@
+comptime {
+    blk: {blk: {}}
+}
+
+// error
+//
+// :2:11: error: redefinition of label 'blk'
+// :2:5: note: previous definition here
test/incremental/unwrap_error_union_simple_errors.0.zig
@@ -0,0 +1,10 @@
+pub fn main() void {
+    maybeErr() catch unreachable;
+}
+
+fn maybeErr() !void {
+    return;
+}
+
+// run
+//
test/incremental/unwrap_error_union_simple_errors.1.zig
@@ -0,0 +1,11 @@
+pub fn main() void {
+    maybeErr() catch return;
+    unreachable;
+}
+
+fn maybeErr() !void {
+    return error.NoWay;
+}
+
+// run
+//
test/incremental/variable_shadowing.0.zig
@@ -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
test/incremental/variable_shadowing.1.zig
@@ -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
test/incremental/variable_shadowing.2.zig
@@ -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
test/incremental/variable_shadowing.3.zig
@@ -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
test/incremental/variable_shadowing.4.zig
@@ -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
test/incremental/variable_shadowing.5.zig
@@ -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
test/incremental/variable_shadowing.6.zig
@@ -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
test/incremental/variable_shadowing.7.zig
@@ -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
test/incremental/variable_shadowing.8.zig
@@ -0,0 +1,9 @@
+pub fn main() void {
+    var i = 0;
+    if (true) |i| {} else |e| {}
+}
+
+// error
+//
+// :3:16: error: redeclaration of local variable 'i'
+// :2:9: note: previous declaration here
test/incremental/variable_shadowing.9.zig
@@ -0,0 +1,9 @@
+pub fn main() void {
+    var i = 0;
+    if (true) |_| {} else |i| {}
+}
+
+// error
+//
+// :3:28: error: redeclaration of local variable 'i'
+// :2:9: note: previous declaration here