From 97b781955eca7c3fc6ee2713f8b5e355645fff58 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 27 Apr 2022 15:37:54 +0200 Subject: [PATCH] test: fix incorrect default target spec; port all incremental tests --- src/test.zig | 2 +- ..._slice_element_by_index_slice_elem_val.zig | 17 +++++++++ test/incremental/ambiguous_reference.zig | 13 +++++++ .../bad_inferred_variable_type.zig | 9 +++++ test/incremental/break_continue.0.zig | 9 +++++ test/incremental/break_continue.1.zig | 8 +++++ test/incremental/break_continue.2.zig | 10 ++++++ test/incremental/break_continue.3.zig | 10 ++++++ test/incremental/catch_at_comptime.0.zig | 11 ++++++ test/incremental/catch_at_comptime.1.zig | 11 ++++++ test/incremental/catch_at_comptime.2.zig | 11 ++++++ test/incremental/catch_at_comptime.3.zig | 10 ++++++ test/incremental/catch_at_comptime.4.zig | 10 ++++++ test/incremental/compile_error.zig | 7 ++++ ...ompile_error_in_inline_fn_call_fixed.0.zig | 16 +++++++++ ...ompile_error_in_inline_fn_call_fixed.1.zig | 13 +++++++ test/incremental/compile_log.0.zig | 17 +++++++++ test/incremental/compile_log.1.zig | 16 +++++++++ test/incremental/comptime_var.0.zig | 12 +++++++ test/incremental/comptime_var.1.zig | 13 +++++++ test/incremental/comptime_var.2.zig | 34 ++++++++++++++++++ test/incremental/comptime_var.3.zig | 10 ++++++ test/incremental/comptime_var.4.zig | 9 +++++ test/incremental/comptime_var.5.zig | 15 ++++++++ test/incremental/comptime_var.6.zig | 32 +++++++++++++++++ test/incremental/double_ampersand.0.zig | 6 ++++ test/incremental/double_ampersand.1.zig | 11 ++++++ test/incremental/double_ampersand.2.zig | 7 ++++ .../extern_variable_has_no_type.0.zig | 9 +++++ .../extern_variable_has_no_type.1.zig | 8 +++++ test/incremental/function_redeclaration.zig | 14 ++++++++ .../global_variable_redeclaration.zig | 8 +++++ ...ello_world_with_updates_x86_64_linux.0.zig | 5 +++ ...ello_world_with_updates_x86_64_linux.1.zig | 5 +++ ...ello_world_with_updates_x86_64_linux.2.zig | 32 +++++++++++++++++ ...ello_world_with_updates_x86_64_linux.3.zig | 20 +++++++++++ ...ello_world_with_updates_x86_64_linux.4.zig | 20 +++++++++++ ...ello_world_with_updates_x86_64_linux.5.zig | 22 ++++++++++++ ...ello_world_with_updates_x86_64_macos.0.zig | 5 +++ ...ello_world_with_updates_x86_64_macos.1.zig | 5 +++ ...ello_world_with_updates_x86_64_macos.2.zig | 19 ++++++++++ ...ello_world_with_updates_x86_64_macos.3.zig | 16 +++++++++ ...ello_world_with_updates_x86_64_macos.4.zig | 22 ++++++++++++ ...ello_world_with_updates_x86_64_macos.5.zig | 16 +++++++++ ...ello_world_with_updates_x86_64_macos.6.zig | 18 ++++++++++ .../inline_assembly_x86_64_linux.0.zig | 16 +++++++++ .../inline_assembly_x86_64_linux.1.zig | 15 ++++++++ .../inline_assembly_x86_64_linux.2.zig | 12 +++++++ .../inline_assembly_x86_64_linux.3.zig | 12 +++++++ .../inner_func_accessing_outer_var.zig | 15 ++++++++ test/incremental/int_to_ptr.0.zig | 8 +++++ test/incremental/int_to_ptr.1.zig | 7 ++++ ...ee_preserved_regs_working_x86_64_linux.zig | 31 ++++++++++++++++ ...7_miscompilation_with_bool_return_type.zig | 18 ++++++++++ .../load_store_via_pointer_deref.0.zig | 16 +++++++++ .../load_store_via_pointer_deref.1.zig | 16 +++++++++ .../load_store_via_pointer_deref.2.zig | 16 +++++++++ .../lower_unnamed_consts_structs.0.zig | 25 +++++++++++++ .../lower_unnamed_consts_structs.1.zig | 35 +++++++++++++++++++ .../lower_unnamed_consts_structs.2.zig | 25 +++++++++++++ test/incremental/merge_error_sets.0.zig | 18 ++++++++++ test/incremental/merge_error_sets.1.zig | 9 +++++ ...ion_and_it_gets_updated_x86_64_linux.0.zig | 13 +++++++ ...ion_and_it_gets_updated_x86_64_linux.1.zig | 12 +++++++ test/incremental/optional_payload.0.zig | 19 ++++++++++ test/incremental/optional_payload.1.zig | 17 +++++++++ test/incremental/optional_payload.2.zig | 18 ++++++++++ test/incremental/optional_payload.3.zig | 18 ++++++++++ test/incremental/orelse_at_comptime.0.zig | 11 ++++++ test/incremental/orelse_at_comptime.1.zig | 11 ++++++ test/incremental/passing_u0_to_function.zig | 9 +++++ .../recursive_inline_function.0.zig | 12 +++++++ .../recursive_inline_function.1.zig | 16 +++++++++ test/incremental/redundant_comptime.0.zig | 7 ++++ test/incremental/redundant_comptime.1.zig | 9 +++++ test/incremental/returns_in_try.zig | 16 +++++++++ test/incremental/runtime_bitwise_and.zig | 16 +++++++++ test/incremental/runtime_bitwise_or.zig | 16 +++++++++ ..._vars_of_different_abi_size_to_stack.0.zig | 16 +++++++++ ..._vars_of_different_abi_size_to_stack.1.zig | 16 +++++++++ ..._vars_of_different_abi_size_to_stack.2.zig | 16 +++++++++ ...g_an_address_space_on_a_local_variable.zig | 8 +++++ .../try_in_comptime_in_struct_in_test.zig | 13 +++++++ test/incremental/type_of.0.zig | 13 +++++++ test/incremental/type_of.1.zig | 11 ++++++ test/incremental/type_of.2.zig | 9 +++++ test/incremental/unused_labels.0.zig | 8 +++++ test/incremental/unused_labels.1.zig | 7 ++++ test/incremental/unused_labels.2.zig | 7 ++++ test/incremental/unused_labels.3.zig | 8 +++++ .../unwrap_error_union_simple_errors.0.zig | 10 ++++++ .../unwrap_error_union_simple_errors.1.zig | 11 ++++++ test/incremental/variable_shadowing.0.zig | 9 +++++ test/incremental/variable_shadowing.1.zig | 9 +++++ test/incremental/variable_shadowing.2.zig | 13 +++++++ test/incremental/variable_shadowing.3.zig | 10 ++++++ test/incremental/variable_shadowing.4.zig | 10 ++++++ test/incremental/variable_shadowing.5.zig | 10 ++++++ test/incremental/variable_shadowing.6.zig | 13 +++++++ test/incremental/variable_shadowing.7.zig | 9 +++++ test/incremental/variable_shadowing.8.zig | 9 +++++ test/incremental/variable_shadowing.9.zig | 9 +++++ 102 files changed, 1360 insertions(+), 1 deletion(-) create mode 100644 test/incremental/access_slice_element_by_index_slice_elem_val.zig create mode 100644 test/incremental/ambiguous_reference.zig create mode 100644 test/incremental/bad_inferred_variable_type.zig create mode 100644 test/incremental/break_continue.0.zig create mode 100644 test/incremental/break_continue.1.zig create mode 100644 test/incremental/break_continue.2.zig create mode 100644 test/incremental/break_continue.3.zig create mode 100644 test/incremental/catch_at_comptime.0.zig create mode 100644 test/incremental/catch_at_comptime.1.zig create mode 100644 test/incremental/catch_at_comptime.2.zig create mode 100644 test/incremental/catch_at_comptime.3.zig create mode 100644 test/incremental/catch_at_comptime.4.zig create mode 100644 test/incremental/compile_error.zig create mode 100644 test/incremental/compile_error_in_inline_fn_call_fixed.0.zig create mode 100644 test/incremental/compile_error_in_inline_fn_call_fixed.1.zig create mode 100644 test/incremental/compile_log.0.zig create mode 100644 test/incremental/compile_log.1.zig create mode 100644 test/incremental/comptime_var.0.zig create mode 100644 test/incremental/comptime_var.1.zig create mode 100644 test/incremental/comptime_var.2.zig create mode 100644 test/incremental/comptime_var.3.zig create mode 100644 test/incremental/comptime_var.4.zig create mode 100644 test/incremental/comptime_var.5.zig create mode 100644 test/incremental/comptime_var.6.zig create mode 100644 test/incremental/double_ampersand.0.zig create mode 100644 test/incremental/double_ampersand.1.zig create mode 100644 test/incremental/double_ampersand.2.zig create mode 100644 test/incremental/extern_variable_has_no_type.0.zig create mode 100644 test/incremental/extern_variable_has_no_type.1.zig create mode 100644 test/incremental/function_redeclaration.zig create mode 100644 test/incremental/global_variable_redeclaration.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_linux.0.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_linux.1.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_linux.2.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_linux.3.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_linux.4.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_linux.5.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.0.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.1.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.2.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.3.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.4.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.5.zig create mode 100644 test/incremental/hello_world_with_updates_x86_64_macos.6.zig create mode 100644 test/incremental/inline_assembly_x86_64_linux.0.zig create mode 100644 test/incremental/inline_assembly_x86_64_linux.1.zig create mode 100644 test/incremental/inline_assembly_x86_64_linux.2.zig create mode 100644 test/incremental/inline_assembly_x86_64_linux.3.zig create mode 100644 test/incremental/inner_func_accessing_outer_var.zig create mode 100644 test/incremental/int_to_ptr.0.zig create mode 100644 test/incremental/int_to_ptr.1.zig create mode 100644 test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig create mode 100644 test/incremental/issue_7187_miscompilation_with_bool_return_type.zig create mode 100644 test/incremental/load_store_via_pointer_deref.0.zig create mode 100644 test/incremental/load_store_via_pointer_deref.1.zig create mode 100644 test/incremental/load_store_via_pointer_deref.2.zig create mode 100644 test/incremental/lower_unnamed_consts_structs.0.zig create mode 100644 test/incremental/lower_unnamed_consts_structs.1.zig create mode 100644 test/incremental/lower_unnamed_consts_structs.2.zig create mode 100644 test/incremental/merge_error_sets.0.zig create mode 100644 test/incremental/merge_error_sets.1.zig create mode 100644 test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig create mode 100644 test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig create mode 100644 test/incremental/optional_payload.0.zig create mode 100644 test/incremental/optional_payload.1.zig create mode 100644 test/incremental/optional_payload.2.zig create mode 100644 test/incremental/optional_payload.3.zig create mode 100644 test/incremental/orelse_at_comptime.0.zig create mode 100644 test/incremental/orelse_at_comptime.1.zig create mode 100644 test/incremental/passing_u0_to_function.zig create mode 100644 test/incremental/recursive_inline_function.0.zig create mode 100644 test/incremental/recursive_inline_function.1.zig create mode 100644 test/incremental/redundant_comptime.0.zig create mode 100644 test/incremental/redundant_comptime.1.zig create mode 100644 test/incremental/returns_in_try.zig create mode 100644 test/incremental/runtime_bitwise_and.zig create mode 100644 test/incremental/runtime_bitwise_or.zig create mode 100644 test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig create mode 100644 test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig create mode 100644 test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig create mode 100644 test/incremental/setting_an_address_space_on_a_local_variable.zig create mode 100644 test/incremental/try_in_comptime_in_struct_in_test.zig create mode 100644 test/incremental/type_of.0.zig create mode 100644 test/incremental/type_of.1.zig create mode 100644 test/incremental/type_of.2.zig create mode 100644 test/incremental/unused_labels.0.zig create mode 100644 test/incremental/unused_labels.1.zig create mode 100644 test/incremental/unused_labels.2.zig create mode 100644 test/incremental/unused_labels.3.zig create mode 100644 test/incremental/unwrap_error_union_simple_errors.0.zig create mode 100644 test/incremental/unwrap_error_union_simple_errors.1.zig create mode 100644 test/incremental/variable_shadowing.0.zig create mode 100644 test/incremental/variable_shadowing.1.zig create mode 100644 test/incremental/variable_shadowing.2.zig create mode 100644 test/incremental/variable_shadowing.3.zig create mode 100644 test/incremental/variable_shadowing.4.zig create mode 100644 test/incremental/variable_shadowing.5.zig create mode 100644 test/incremental/variable_shadowing.6.zig create mode 100644 test/incremental/variable_shadowing.7.zig create mode 100644 test/incremental/variable_shadowing.8.zig create mode 100644 test/incremental/variable_shadowing.9.zig diff --git a/src/test.zig b/src/test.zig index e138afecb919f588d684102a2ec518e89abcda7d..2f3389d7fffb7907aac0189092c985d45a35be22 100644 --- a/src/test.zig +++ b/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| { diff --git a/test/incremental/access_slice_element_by_index_slice_elem_val.zig b/test/incremental/access_slice_element_by_index_slice_elem_val.zig new file mode 100644 index 0000000000000000000000000000000000000000..a0bdae0826aa8d982759c837e7e729766ab6a478 --- /dev/null +++ b/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 +// diff --git a/test/incremental/ambiguous_reference.zig b/test/incremental/ambiguous_reference.zig new file mode 100644 index 0000000000000000000000000000000000000000..66144a5645902aea913226486abd12657434367d --- /dev/null +++ b/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 diff --git a/test/incremental/bad_inferred_variable_type.zig b/test/incremental/bad_inferred_variable_type.zig new file mode 100644 index 0000000000000000000000000000000000000000..47ceb9b638185dbc9dafd3ec92900dfa5ad4d4cf --- /dev/null +++ b/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 diff --git a/test/incremental/break_continue.0.zig b/test/incremental/break_continue.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..ac0abdb52dadc98760d9ac2d1b466b185e8bd90d --- /dev/null +++ b/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 +// diff --git a/test/incremental/break_continue.1.zig b/test/incremental/break_continue.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..9e4f79bd14d7a1340b9fcbc02c271790c642bd07 --- /dev/null +++ b/test/incremental/break_continue.1.zig @@ -0,0 +1,8 @@ +pub fn main() void { + foo: while (true) { + break :foo; + } +} + +// run +// diff --git a/test/incremental/break_continue.2.zig b/test/incremental/break_continue.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..ba12f33e3f05b3419a5f3f84631e3d52a3ce9eec --- /dev/null +++ b/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 +// diff --git a/test/incremental/break_continue.3.zig b/test/incremental/break_continue.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..03e224d26545d7c8d67617dd0a4fb609b6d80405 --- /dev/null +++ b/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 +// diff --git a/test/incremental/catch_at_comptime.0.zig b/test/incremental/catch_at_comptime.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..af1545832dee3b3e558a463ebf9ac75ad36b346e --- /dev/null +++ b/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 +// diff --git a/test/incremental/catch_at_comptime.1.zig b/test/incremental/catch_at_comptime.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..e05caeae6d9f058b730777d4868e85850dd776c5 --- /dev/null +++ b/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 +// diff --git a/test/incremental/catch_at_comptime.2.zig b/test/incremental/catch_at_comptime.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..326e6f0b61a4c8a651130c6767a72d77617506a6 --- /dev/null +++ b/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 +// diff --git a/test/incremental/catch_at_comptime.3.zig b/test/incremental/catch_at_comptime.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..d00317f697426e19c149abb0e89ae171d0427f45 --- /dev/null +++ b/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 +// diff --git a/test/incremental/catch_at_comptime.4.zig b/test/incremental/catch_at_comptime.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..57cb602641ded47982e332f2fbe5f484fa64363f --- /dev/null +++ b/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 +// diff --git a/test/incremental/compile_error.zig b/test/incremental/compile_error.zig new file mode 100644 index 0000000000000000000000000000000000000000..dab0f7f7cc9fd2dc36d0bab8dcdaa5b1dbc6fdfb --- /dev/null +++ b/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 diff --git a/test/incremental/compile_error_in_inline_fn_call_fixed.0.zig b/test/incremental/compile_error_in_inline_fn_call_fixed.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..1848490b0794abeb37eddb4f413e96cc013f976a --- /dev/null +++ b/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 diff --git a/test/incremental/compile_error_in_inline_fn_call_fixed.1.zig b/test/incremental/compile_error_in_inline_fn_call_fixed.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..1e61c6c790fd3b9f7bde2c5de0ce5b67421bdc1e --- /dev/null +++ b/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 +// diff --git a/test/incremental/compile_log.0.zig b/test/incremental/compile_log.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..c213ebb930ca78b5b25f6fec55acaf643761afb5 --- /dev/null +++ b/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 diff --git a/test/incremental/compile_log.1.zig b/test/incremental/compile_log.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..12e66415420870549bdff9b0e1964403985d2dd3 --- /dev/null +++ b/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 diff --git a/test/incremental/comptime_var.0.zig b/test/incremental/comptime_var.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..019cf78abb05240d76c1566a4a228734f73db665 --- /dev/null +++ b/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 diff --git a/test/incremental/comptime_var.1.zig b/test/incremental/comptime_var.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..efc51aafe3e7572bb8815d5e75ec4e4b00761499 --- /dev/null +++ b/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 diff --git a/test/incremental/comptime_var.2.zig b/test/incremental/comptime_var.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..e91c0540efc403070b34d902f519056fb48a93c1 --- /dev/null +++ b/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! +// diff --git a/test/incremental/comptime_var.3.zig b/test/incremental/comptime_var.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..d4e6d85d9d38fa74e139ece4b911521069f80acd --- /dev/null +++ b/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 diff --git a/test/incremental/comptime_var.4.zig b/test/incremental/comptime_var.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..74da6ef448edd5534b49b1f850673863b4188b99 --- /dev/null +++ b/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 diff --git a/test/incremental/comptime_var.5.zig b/test/incremental/comptime_var.5.zig new file mode 100644 index 0000000000000000000000000000000000000000..76a06f3d4b5931e8fd23271dcc593e07ff414a7f --- /dev/null +++ b/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 +// diff --git a/test/incremental/comptime_var.6.zig b/test/incremental/comptime_var.6.zig new file mode 100644 index 0000000000000000000000000000000000000000..0eb743a05b11d0d8cb664918f551910b931681a6 --- /dev/null +++ b/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 diff --git a/test/incremental/double_ampersand.0.zig b/test/incremental/double_ampersand.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..b14c30ecb01225e88025b6e0cb1aa7c25c69f1ed --- /dev/null +++ b/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 diff --git a/test/incremental/double_ampersand.1.zig b/test/incremental/double_ampersand.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..cd5bba02fdaa14bd47cc3d1332854865e9aaea49 --- /dev/null +++ b/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 diff --git a/test/incremental/double_ampersand.2.zig b/test/incremental/double_ampersand.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..c6f461d66126f07c9808aacf5160615fc36d7917 --- /dev/null +++ b/test/incremental/double_ampersand.2.zig @@ -0,0 +1,7 @@ +pub fn main() void { + const b: u8 = 1; + _ = &&b; +} + +// run +// diff --git a/test/incremental/extern_variable_has_no_type.0.zig b/test/incremental/extern_variable_has_no_type.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..2f03067b3ac8aba8bfe34a948baece7c2796fe05 --- /dev/null +++ b/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 diff --git a/test/incremental/extern_variable_has_no_type.1.zig b/test/incremental/extern_variable_has_no_type.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..f5c31244e5a7bfe9a39f028fd80f40ebcd3dff04 --- /dev/null +++ b/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 diff --git a/test/incremental/function_redeclaration.zig b/test/incremental/function_redeclaration.zig new file mode 100644 index 0000000000000000000000000000000000000000..a9664646c98a4dcb5b889de88ddfc60ce8d5d8d5 --- /dev/null +++ b/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 diff --git a/test/incremental/global_variable_redeclaration.zig b/test/incremental/global_variable_redeclaration.zig new file mode 100644 index 0000000000000000000000000000000000000000..9a0d5939fbffc35ff3da74a6901cf8d69dec421a --- /dev/null +++ b/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 diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.0.zig b/test/incremental/hello_world_with_updates_x86_64_linux.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..960fae5e644fa67cb8f46decb7c774ae7a0719d1 --- /dev/null +++ b/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' diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.1.zig b/test/incremental/hello_world_with_updates_x86_64_linux.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..0f347b7f5069ccefb13bd680334cbba2a4beb4e7 --- /dev/null +++ b/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 diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.2.zig b/test/incremental/hello_world_with_updates_x86_64_linux.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..fcea1870ce59ef67264c3be650beafabbd5a97e3 --- /dev/null +++ b/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! +// diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.3.zig b/test/incremental/hello_world_with_updates_x86_64_linux.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..7812023372e14acc9c4c93441e913126d1e7de1d --- /dev/null +++ b/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! +// diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.4.zig b/test/incremental/hello_world_with_updates_x86_64_linux.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..cdf47012b8306d2a234871842bfe00da550522de --- /dev/null +++ b/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. +// diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.5.zig b/test/incremental/hello_world_with_updates_x86_64_linux.5.zig new file mode 100644 index 0000000000000000000000000000000000000000..68c1e305f713135321cd2000bdd9b50dc2020c8e --- /dev/null +++ b/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. +// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.0.zig b/test/incremental/hello_world_with_updates_x86_64_macos.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..34440c4603e0c2164ad399efb03d59e4de9cf6ff --- /dev/null +++ b/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' diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.1.zig b/test/incremental/hello_world_with_updates_x86_64_macos.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..909fc9ccfbcb343f761414446c0ec4d52e98aeef --- /dev/null +++ b/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 diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.2.zig b/test/incremental/hello_world_with_updates_x86_64_macos.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..fb8cb39eddf859f843ce61b068c0f6f8f9feb387 --- /dev/null +++ b/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! +// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.3.zig b/test/incremental/hello_world_with_updates_x86_64_macos.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..f6e233886b0a7d616f92dd11ffb4232191c997de --- /dev/null +++ b/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! +// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.4.zig b/test/incremental/hello_world_with_updates_x86_64_macos.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..f89cef73543ce1f3e51a4e0152c0a8c367edf537 --- /dev/null +++ b/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! +// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.5.zig b/test/incremental/hello_world_with_updates_x86_64_macos.5.zig new file mode 100644 index 0000000000000000000000000000000000000000..0d7f97578afe1274d1c8e3d356ce702992edca61 --- /dev/null +++ b/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. +// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.6.zig b/test/incremental/hello_world_with_updates_x86_64_macos.6.zig new file mode 100644 index 0000000000000000000000000000000000000000..3ce2cb717639d663c2679dcdef2a4583c3c3f8ec --- /dev/null +++ b/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. +// diff --git a/test/incremental/inline_assembly_x86_64_linux.0.zig b/test/incremental/inline_assembly_x86_64_linux.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..e3c0f3badbb61fa8a53a63bcabb7b90edbe4657b --- /dev/null +++ b/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 diff --git a/test/incremental/inline_assembly_x86_64_linux.1.zig b/test/incremental/inline_assembly_x86_64_linux.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..b35014b0f6b6afa26cd92e7496edbc70c2b90dbf --- /dev/null +++ b/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 diff --git a/test/incremental/inline_assembly_x86_64_linux.2.zig b/test/incremental/inline_assembly_x86_64_linux.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..1695265ab4ebcbb6a2625bb9abdffb0d751eec07 --- /dev/null +++ b/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 diff --git a/test/incremental/inline_assembly_x86_64_linux.3.zig b/test/incremental/inline_assembly_x86_64_linux.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..765eaeb97eb2f8373afff7399051a2fca6269070 --- /dev/null +++ b/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 diff --git a/test/incremental/inner_func_accessing_outer_var.zig b/test/incremental/inner_func_accessing_outer_var.zig new file mode 100644 index 0000000000000000000000000000000000000000..e30cf58ef84d54e38ecfac903a7e47437d971a68 --- /dev/null +++ b/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 diff --git a/test/incremental/int_to_ptr.0.zig b/test/incremental/int_to_ptr.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..b7c70b90a44ff58c786fa8b18fa3b440caef980f --- /dev/null +++ b/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 diff --git a/test/incremental/int_to_ptr.1.zig b/test/incremental/int_to_ptr.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..72c8c8c9d6f06d8c7d4e4d49219106160beae122 --- /dev/null +++ b/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 diff --git a/test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig b/test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig new file mode 100644 index 0000000000000000000000000000000000000000..4c045496da446fc709a1ba8ffe1cf16c46356104 --- /dev/null +++ b/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 +// diff --git a/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig b/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig new file mode 100644 index 0000000000000000000000000000000000000000..3aed8685bfb744da97bfc4cdf7f175daba803ac5 --- /dev/null +++ b/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 +// diff --git a/test/incremental/load_store_via_pointer_deref.0.zig b/test/incremental/load_store_via_pointer_deref.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..96aedf3196a50338de8f90f084da7bbec8fdc8a2 --- /dev/null +++ b/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 +// diff --git a/test/incremental/load_store_via_pointer_deref.1.zig b/test/incremental/load_store_via_pointer_deref.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..e31109274448887f9d914324df19bfbc5963dca9 --- /dev/null +++ b/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 +// diff --git a/test/incremental/load_store_via_pointer_deref.2.zig b/test/incremental/load_store_via_pointer_deref.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..3b1484faa10ade80cdb7039c309b05ae4f58d860 --- /dev/null +++ b/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 +// diff --git a/test/incremental/lower_unnamed_consts_structs.0.zig b/test/incremental/lower_unnamed_consts_structs.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..31232996461ac972b886c5bb30b9c91ff6840d52 --- /dev/null +++ b/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 +// diff --git a/test/incremental/lower_unnamed_consts_structs.1.zig b/test/incremental/lower_unnamed_consts_structs.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..37afdc8a09c0f08f0351a4d0201416e17455b07b --- /dev/null +++ b/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 +// diff --git a/test/incremental/lower_unnamed_consts_structs.2.zig b/test/incremental/lower_unnamed_consts_structs.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..b437c4a030aae4842b371abef19074f27b76d556 --- /dev/null +++ b/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 +// diff --git a/test/incremental/merge_error_sets.0.zig b/test/incremental/merge_error_sets.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..f1f3b968830988d3d8e6105f1bd97d49345a8d08 --- /dev/null +++ b/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 +// diff --git a/test/incremental/merge_error_sets.1.zig b/test/incremental/merge_error_sets.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..81c1cad134ec58f46201197a827608b88389f344 --- /dev/null +++ b/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 diff --git a/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig b/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..ecba1c8133714f48d0423b98c9a213a057550ad1 --- /dev/null +++ b/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 +// diff --git a/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig b/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..529acbcf38132bb09f0a47adc2a128ac7c7b7ac5 --- /dev/null +++ b/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 +// diff --git a/test/incremental/optional_payload.0.zig b/test/incremental/optional_payload.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..65296875ff1c27542bf6ee87b3e66d720b023cf5 --- /dev/null +++ b/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 +// diff --git a/test/incremental/optional_payload.1.zig b/test/incremental/optional_payload.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..2d4dafffb9bdb898c20465beba6ec86a7ef54985 --- /dev/null +++ b/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 +// diff --git a/test/incremental/optional_payload.2.zig b/test/incremental/optional_payload.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..608310923bad2f4a376c63f6673c7f66c2275679 --- /dev/null +++ b/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 +// diff --git a/test/incremental/optional_payload.3.zig b/test/incremental/optional_payload.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..b81ec398c7a28ed88b5dab7295fcbf9fafa19c83 --- /dev/null +++ b/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 +// diff --git a/test/incremental/orelse_at_comptime.0.zig b/test/incremental/orelse_at_comptime.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..5397ca3b0afae077fb60745b35c3011576c8a49d --- /dev/null +++ b/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 +// diff --git a/test/incremental/orelse_at_comptime.1.zig b/test/incremental/orelse_at_comptime.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..7d4fcd3178a34fc251f78f49b54857c759dc9254 --- /dev/null +++ b/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 +// diff --git a/test/incremental/passing_u0_to_function.zig b/test/incremental/passing_u0_to_function.zig new file mode 100644 index 0000000000000000000000000000000000000000..f84c30be8a4128afa10d50a576ad2600bc8ad5a0 --- /dev/null +++ b/test/incremental/passing_u0_to_function.zig @@ -0,0 +1,9 @@ +pub fn main() void { + doNothing(0); +} +fn doNothing(arg: u0) void { + _ = arg; +} + +// run +// diff --git a/test/incremental/recursive_inline_function.0.zig b/test/incremental/recursive_inline_function.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..c8333c906516bccd45128a99106fc510a0ea4d9f --- /dev/null +++ b/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 +// diff --git a/test/incremental/recursive_inline_function.1.zig b/test/incremental/recursive_inline_function.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..139da1c371292c2cbf196d87c3cb80c4fcd3315b --- /dev/null +++ b/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 diff --git a/test/incremental/redundant_comptime.0.zig b/test/incremental/redundant_comptime.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..c1ecbf7acec79ac1c60f9f09780e317b609ccd12 --- /dev/null +++ b/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 diff --git a/test/incremental/redundant_comptime.1.zig b/test/incremental/redundant_comptime.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..79226ae8a6b2799dc4e87cfad71219f09a47fc34 --- /dev/null +++ b/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 diff --git a/test/incremental/returns_in_try.zig b/test/incremental/returns_in_try.zig new file mode 100644 index 0000000000000000000000000000000000000000..de5a9a3258288c1357d96172f1e8458abe45d4d1 --- /dev/null +++ b/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 diff --git a/test/incremental/runtime_bitwise_and.zig b/test/incremental/runtime_bitwise_and.zig new file mode 100644 index 0000000000000000000000000000000000000000..3ba3d3124cc400d5ccd309f392c3fd2c593732e3 --- /dev/null +++ b/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 +// diff --git a/test/incremental/runtime_bitwise_or.zig b/test/incremental/runtime_bitwise_or.zig new file mode 100644 index 0000000000000000000000000000000000000000..b97c2acf0228a3314eccb4ab859eee3a7dc2d77b --- /dev/null +++ b/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 +// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..6134622a0e6e1793b08c53b2b89356569e6bf0e4 --- /dev/null +++ b/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 +// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..4d87d7b9c5d6cc99833537eeefa60ff250432ab0 --- /dev/null +++ b/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 +// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..b6652279624630d277f955d2b07366bb90a05afd --- /dev/null +++ b/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 +// diff --git a/test/incremental/setting_an_address_space_on_a_local_variable.zig b/test/incremental/setting_an_address_space_on_a_local_variable.zig new file mode 100644 index 0000000000000000000000000000000000000000..dad282dc318cdf22005f31b55a5eda38bd8018a4 --- /dev/null +++ b/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' diff --git a/test/incremental/try_in_comptime_in_struct_in_test.zig b/test/incremental/try_in_comptime_in_struct_in_test.zig new file mode 100644 index 0000000000000000000000000000000000000000..e88aa13a7b05977ee51d2b63f20baa8f76af159f --- /dev/null +++ b/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 diff --git a/test/incremental/type_of.0.zig b/test/incremental/type_of.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..d8a97d144470eff0d74fb59464146a17c52f328d --- /dev/null +++ b/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 +// diff --git a/test/incremental/type_of.1.zig b/test/incremental/type_of.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..86d7d87a19da452234bebb83b69d8cb0ee1fa1a8 --- /dev/null +++ b/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 +// diff --git a/test/incremental/type_of.2.zig b/test/incremental/type_of.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..cdbc8121fd71bc5f6603e8c2ab399154ba9b0c84 --- /dev/null +++ b/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 diff --git a/test/incremental/unused_labels.0.zig b/test/incremental/unused_labels.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..9afa5facdde2c412bd30cd0d43463c2f90cd2cf2 --- /dev/null +++ b/test/incremental/unused_labels.0.zig @@ -0,0 +1,8 @@ +comptime { + foo: {} +} + +// error +// output_mode=Exe +// +// :2:5: error: unused block label diff --git a/test/incremental/unused_labels.1.zig b/test/incremental/unused_labels.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..c7ff576875dcea1d493816bb78ee56b863023707 --- /dev/null +++ b/test/incremental/unused_labels.1.zig @@ -0,0 +1,7 @@ +comptime { + foo: while (true) {} +} + +// error +// +// :2:5: error: unused while loop label diff --git a/test/incremental/unused_labels.2.zig b/test/incremental/unused_labels.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..babe3c7b0a1dda7aac83115faf4c60d00aa06543 --- /dev/null +++ b/test/incremental/unused_labels.2.zig @@ -0,0 +1,7 @@ +comptime { + foo: for ("foo") |_| {} +} + +// error +// +// :2:5: error: unused for loop label diff --git a/test/incremental/unused_labels.3.zig b/test/incremental/unused_labels.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..e4f3ac05a404667fb60cad6f5fc8bfe43abb457c --- /dev/null +++ b/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 diff --git a/test/incremental/unwrap_error_union_simple_errors.0.zig b/test/incremental/unwrap_error_union_simple_errors.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..a1e2da9340d62b4e7401f5a1ccaba75b1832769a --- /dev/null +++ b/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 +// diff --git a/test/incremental/unwrap_error_union_simple_errors.1.zig b/test/incremental/unwrap_error_union_simple_errors.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..830ee629bce852b3957bff97e0d7d845d6d8dbee --- /dev/null +++ b/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 +// diff --git a/test/incremental/variable_shadowing.0.zig b/test/incremental/variable_shadowing.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..0ab53a78f929e43ba4edb678f290b05dd042b35f --- /dev/null +++ b/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 diff --git a/test/incremental/variable_shadowing.1.zig b/test/incremental/variable_shadowing.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..af24af038dfc0da511879b35a0edd97415320621 --- /dev/null +++ b/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 diff --git a/test/incremental/variable_shadowing.2.zig b/test/incremental/variable_shadowing.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..a44372f9b978ce8ed3eef164ce81364637fb2313 --- /dev/null +++ b/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 diff --git a/test/incremental/variable_shadowing.3.zig b/test/incremental/variable_shadowing.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..89288705e1b1d70326edefcc81da2ae02cca7ecf --- /dev/null +++ b/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 diff --git a/test/incremental/variable_shadowing.4.zig b/test/incremental/variable_shadowing.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..b798cc13c1dc018a136fcca8ef4548839b8130fd --- /dev/null +++ b/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 diff --git a/test/incremental/variable_shadowing.5.zig b/test/incremental/variable_shadowing.5.zig new file mode 100644 index 0000000000000000000000000000000000000000..484d218ea20e1e46451a1947d8bbedd5aef61d95 --- /dev/null +++ b/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 diff --git a/test/incremental/variable_shadowing.6.zig b/test/incremental/variable_shadowing.6.zig new file mode 100644 index 0000000000000000000000000000000000000000..3e53c4da2fcbb95783caf037ff8849ddd8d07999 --- /dev/null +++ b/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 diff --git a/test/incremental/variable_shadowing.7.zig b/test/incremental/variable_shadowing.7.zig new file mode 100644 index 0000000000000000000000000000000000000000..95888839a7107a446c9e850946b4f4484d599f00 --- /dev/null +++ b/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 diff --git a/test/incremental/variable_shadowing.8.zig b/test/incremental/variable_shadowing.8.zig new file mode 100644 index 0000000000000000000000000000000000000000..57e616e1d699d2123eb62fc92acda0a0ec02e4fc --- /dev/null +++ b/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 diff --git a/test/incremental/variable_shadowing.9.zig b/test/incremental/variable_shadowing.9.zig new file mode 100644 index 0000000000000000000000000000000000000000..b8a1198aed4608b4c8fde8f40e3f2f04fdcdef5a --- /dev/null +++ b/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 -- 2.54.0