0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
zig/test/behavior
mlugg d11bbde5f9
compiler: remove anonymous struct types, unify all tuples
This commit reworks how anonymous struct literals and tuples work.

Previously, an untyped anonymous struct literal
(e.g. `const x = .{ .a = 123 }`) was given an "anonymous struct type",
which is a special kind of struct which coerces using structural
equivalence. This mechanism was a holdover from before we used
RLS / result types as the primary mechanism of type inference. This
commit changes the language so that the type assigned here is a "normal"
struct type. It uses a form of equivalence based on the AST node and the
type's structure, much like a reified (`@Type`) type.

Additionally, tuples have been simplified. The distinction between
"simple" and "complex" tuple types is eliminated. All tuples, even those
explicitly declared using `struct { ... }` syntax, use structural
equivalence, and do not undergo staged type resolution. Tuples are very
restricted: they cannot have non-`auto` layouts, cannot have aligned
fields, and cannot have default values with the exception of `comptime`
fields. Tuples currently do not have optimized layout, but this can be
changed in the future.

This change simplifies the language, and fixes some problematic
coercions through pointers which led to unintuitive behavior.

Resolves: #16865
History 2024-10-31 20:42:53 +00:00
..
conflicting_externs categorize behavior/bugs/<issueno>.zig tests 2024-01-06 16:49:41 -08:00
hasdecl move behavior tests from test/stage1/ to test/ 2021-04-29 15:54:04 -07:00
import move behavior tests from test/stage1/ to test/ 2021-04-29 15:54:04 -07:00
namespace_depends_on_compile_var move behavior tests from test/stage1/ to test/ 2021-04-29 15:54:04 -07:00
pub_enum move behavior tests from test/stage1/ to test/ 2021-04-29 15:54:04 -07:00
usingnamespace compiler: split Decl into Nav and Cau 2024-08-11 07:29:41 +01:00
abs.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
align.zig Merge pull request #21697 from mlugg/callconv 2024-10-23 16:48:33 +01:00
alignof.zig riscv: arbitrary sized arrays 2024-06-13 02:19:40 -07:00
array.zig compiler: remove anonymous struct types, unify all tuples 2024-10-31 20:42:53 +00:00
asm.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
async_fn.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
atomics.zig remove @fence (#21585) 2024-10-04 22:21:27 +00:00
await_struct.zig test: update behavior to silence 'var is never mutated' errors 2023-11-19 09:57:03 +00:00
basic.zig tests: re-enable tests that now pass on aarch64-windows 2024-10-22 11:39:29 +02:00
bit_shifting.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
bitcast.zig test: Re-enable "bitcast nan float does not modify signaling bit" for LLVM + arm. 2024-10-02 04:08:24 +02:00
bitreverse.zig stage2-wasm: bit_reverse 2024-06-16 11:53:33 +02:00
bool.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
builtin_functions_returning_void_or_noreturn.zig test: update for CallingConvention changes 2024-10-19 19:15:23 +01:00
byteswap.zig riscv: clean up and unify encoding logic 2024-07-26 04:19:13 -07:00
byval_arg_var.zig riscv: rewrite "binOp" 2024-06-13 02:24:39 -07:00
call.zig test: Re-enable a bunch of behavior tests with LLVM. 2024-09-12 07:28:37 +02:00
call_tail.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
cast.zig compiler: remove anonymous struct types, unify all tuples 2024-10-31 20:42:53 +00:00
cast_int.zig riscv: implement errunion_payload_ptr_set 2024-09-01 17:34:06 +01:00
comptime_memory.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
const_slice_child.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
decl_literals.zig spirv: skip range switch tests 2024-10-13 01:58:11 +02:00
decltest.zig riscv: math progress 2024-05-11 02:17:24 -07:00
defer.zig AstGen: update @errorCast to maybe eval to err 2024-09-03 22:56:23 +01:00
destructure.zig riscv: implement more operators 2024-07-26 04:05:39 -07:00
duplicated_test_names.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
empty_union.zig riscv: std.fmt.format running 2024-06-13 02:20:47 -07:00
enum.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
error.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
eval.zig spirv: skip range switch tests 2024-10-13 01:58:11 +02:00
export_builtin.zig lib,test,tools,doc: update usages of @export 2024-08-27 00:44:35 +01:00
export_c_keywords.zig lib,test,tools,doc: update usages of @export 2024-08-27 00:44:35 +01:00
export_keyword.zig Sema: mark export on owner nav when exporting function alias 2024-09-18 21:42:47 +01:00
export_self_referential_type_info.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
extern.zig elf: fix up riscv for .got.zig rewrite 2024-08-15 08:53:41 +02:00
extern_struct_zero_size_fields.zig test: update behavior to silence 'var is never mutated' errors 2023-11-19 09:57:03 +00:00
field_parent_ptr.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
file_to_embed.txt rename behavior test to better describe what it does 2023-10-23 17:28:10 -07:00
floatop.zig test: Re-enable a bunch of behavior tests with LLVM. 2024-09-12 07:28:37 +02:00
fn.zig Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
fn_delegation.zig riscv: std.fmt.format running 2024-06-13 02:20:47 -07:00
fn_in_struct_in_comptime.zig test: update behavior to silence 'var is never mutated' errors 2023-11-19 09:57:03 +00:00
for.zig riscv: update tests and fix reuse bug 2024-07-26 04:19:58 -07:00
generics.zig tests: re-enable tests that now pass on aarch64-windows 2024-10-22 11:39:29 +02:00
globals.zig riscv: remove redundant assert in genBinOp 2024-07-26 04:05:41 -07:00
hasdecl.zig spirv: disable tests that fail on pocl 2024-06-10 20:32:34 +02:00
hasfield.zig Sema: make @hasField support tuples too 2022-03-11 12:59:20 -07:00
if.zig riscv: make multi-threaded enabled compilation the default 2024-07-26 14:53:55 -07:00
import.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
import_c_keywords.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
incomplete_struct_param_tld.zig riscv: std.fmt.format running 2024-06-13 02:20:47 -07:00
inline_switch.zig spirv: skip range switch tests 2024-10-13 01:58:11 +02:00
int128.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
int_comparison_elision.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
ir_block_deps.zig riscv: std.fmt.format running 2024-06-13 02:20:47 -07:00
lower_strlit_to_vector.zig riscv: add airAggregateInit for arrays 2024-06-13 02:22:04 -07:00
math.zig spirv: skip range switch tests 2024-10-13 01:58:11 +02:00
maximum_minimum.zig Sema: don't emit instruction when casting @min/@max result to OPV type 2024-09-15 17:52:35 +01:00
member_func.zig riscv: std.fmt.format running 2024-06-13 02:20:47 -07:00
memcpy.zig riscv: airAsm rewrite 2024-07-26 04:19:55 -07:00
memset.zig riscv: std.fmt.format running 2024-06-13 02:20:47 -07:00
merge_error_sets.zig riscv: std.fmt.format running 2024-06-13 02:20:47 -07:00
muladd.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
multiple_externs_with_conflicting_types.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
namespace_depends_on_compile_var.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
nan.zig riscv: rewrite "binOp" 2024-06-13 02:24:39 -07:00
null.zig riscv: make multi-threaded enabled compilation the default 2024-07-26 14:53:55 -07:00
optional.zig riscv: implement optional_payload_ptr_set 2024-09-12 20:29:10 -04:00
packed-struct.zig implement packed struct equality (#21679) 2024-10-12 20:59:12 -07:00
packed-union.zig behavior: avoid field/decl name conflicts 2024-08-29 23:43:52 +01:00
packed_struct_explicit_backing_int.zig riscv: finally fix bug + airAggregateInit 2024-05-11 02:17:24 -07:00
pointers.zig spirv: skip range switch tests 2024-10-13 01:58:11 +02:00
popcount.zig riscv: update tests and fix reuse bug 2024-07-26 04:19:58 -07:00
prefetch.zig riscv: add airAggregateInit for arrays 2024-06-13 02:22:04 -07:00
ptrcast.zig riscv: rewrite "binOp" 2024-06-13 02:24:39 -07:00
ptrfromint.zig riscv: implement optional logic 2024-06-13 02:22:33 -07:00
pub_enum.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
ref_var_in_if_after_if_2nd_switch_prong.zig riscv: switch progress + by-ref return progress 2024-06-13 02:19:38 -07:00
reflection.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
return_address.zig riscv: arbitrary sized arrays 2024-06-13 02:19:40 -07:00
saturating_arithmetic.zig stage2-wasm: mul_sat 32 bits <=, i64, i128 2024-07-23 17:06:18 +02:00
select.zig spirv: new vectorization helper 2024-06-10 20:32:49 +02:00
shuffle.zig tests: re-enable tests that now pass on aarch64-windows 2024-10-22 11:39:29 +02:00
sizeof_and_typeof.zig riscv: vectors part 3 2024-07-14 23:02:35 -07:00
slice.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
slice_sentinel_comptime.zig spirv: update tests 2024-02-04 19:09:33 +01:00
src.zig language: add module name field to @src 2024-08-08 07:47:14 -07:00
string_literals.zig riscv: enable passing tests 2024-07-26 04:19:17 -07:00
struct.zig compiler: remove anonymous struct types, unify all tuples 2024-10-31 20:42:53 +00:00
struct_contains_null_ptr_itself.zig riscv: implement optional logic 2024-06-13 02:22:33 -07:00
struct_contains_slice_of_itself.zig riscv: rewrite "binOp" 2024-06-13 02:24:39 -07:00
switch.zig spirv: skip range switch tests 2024-10-13 01:58:11 +02:00
switch_loop.zig riscv: implement switch_dispatch & loop_switch_br 2024-09-01 18:31:01 +01:00
switch_on_captured_error.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
switch_prong_err_enum.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
switch_prong_implicit_cast.zig riscv: update tests and fix reuse bug 2024-07-26 04:19:58 -07:00
this.zig riscv: truncate airStructFieldVal result 2024-07-14 23:02:33 -07:00
threadlocal.zig test: Re-enable a bunch of behavior tests with LLVM. 2024-09-12 07:28:37 +02:00
truncate.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
try.zig Sema: give try operand error{} result type in non-errorable functions 2024-09-15 16:51:26 +01:00
tuple.zig compiler: remove anonymous struct types, unify all tuples 2024-10-31 20:42:53 +00:00
tuple_declarations.zig compiler: remove anonymous struct types, unify all tuples 2024-10-31 20:42:53 +00:00
type.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
type_info.zig riscv: disable failing test 2024-10-19 20:06:04 +01:00
type_info_mul_linksection_addrspace_decls.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
typename.zig test: update for CallingConvention changes 2024-10-19 19:15:23 +01:00
undefined.zig riscv: rewrite "binOp" 2024-06-13 02:24:39 -07:00
underscore.zig riscv: std.fmt.format running 2024-06-13 02:20:47 -07:00
union.zig compiler: remove anonymous struct types, unify all tuples 2024-10-31 20:42:53 +00:00
union_with_members.zig riscv: update tests and fix reuse bug 2024-07-26 04:19:58 -07:00
usingnamespace.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
var_args.zig std: add arch bits for s390x-linux (#21342) 2024-09-24 13:35:12 -07:00
vector.zig test: Re-enable store vector with memset for LLVM. 2024-09-19 18:20:21 -07:00
void.zig riscv: implement optional logic 2024-06-13 02:22:33 -07:00
wasm.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
while.zig riscv: implement errunion_payload_ptr_set 2024-09-01 17:34:06 +01:00
widening.zig riscv: rewrite "binOp" 2024-06-13 02:24:39 -07:00
wrapping_arithmetic.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
zero.bin Module: fix @embedFile of files containing zero bytes 2024-02-22 12:33:53 -08:00