aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/array.zig
AgeCommit message (Collapse)Author
2024-01-15test/behavior: replace all 'comptime expect' with 'comptime assert'dweiller
2024-01-06categorize `behavior/bugs/<issueno>.zig` testsVeikka Tuominen
2023-11-19test: update behavior to silence 'var is never mutated' errorsmlugg
2023-10-15spirv: update failing / passing testsRobin Voetter
Some tests are now failing due to debug info changes, some tests now pass due to improved compiler functionality.
2023-10-15spirv: allow generation of *i0Robin Voetter
2023-09-23compiler: preserve result type information through address-of operatormlugg
This commit introduces the new `ref_coerced_ty` result type into AstGen. This represents a expression which we want to treat as an lvalue, and the pointer will be coerced to a given type. This change gives known result types to many expressions, in particular struct and array initializations. This allows certain casts to work which previously required explicitly specifying types via `@as`. It also eliminates our dependence on anonymous struct types for expressions of the form `&.{ ... }` - this paves the way for #16865, and also results in less Sema magic happening for such initializations, also leading to potentially better runtime code. As part of these changes, this commit also implements #17194 by disallowing RLS on explicitly-typed struct and array initializations. Apologies for linking these changes - it seemed rather pointless to try and separate them, since they both make big changes to struct and array initializations in AstGen. The rationale for this change can be found in the proposal - in essence, performing RLS whilst maintaining the semantics of the intermediary type is a very difficult problem to solve. This allowed the problematic `coerce_result_ptr` ZIR instruction to be completely eliminated, which in turn also simplified the logic for inferred allocations in Sema - thanks to this, we almost break even on line count! In doing this, the ZIR instructions surrounding these initializations have been restructured - some have been added and removed, and others renamed for clarity (and their semantics changed slightly). In order to optimize ZIR tag count, the `struct_init_anon_ref` and `array_init_anon_ref` instructions have been removed in favour of using `ref` on a standard anonymous value initialization, since these instructions are now virtually never used. Lastly, it's worth noting that this commit introduces a slightly strange source of generic poison types: in the expression `@as(*anyopaque, &x)`, the sub-expression `x` has a generic poison result type, despite no generic code being involved. This turns out to be a logical choice, because we don't know the result type for `x`, and the generic poison type represents precisely this case, providing the semantics we need. Resolves: #16512 Resolves: #17194
2023-09-23spirv: enable passing testsRobin Voetter
2023-09-23spirv: generate module initializerRobin Voetter
2023-09-23spirv: air array_elem_val using hackRobin Voetter
SPIR-V doesn't support true element indexing, so we probably need to switch over to isByRef like in llvm for this to work properly. Currently a temporary is used, which at least seems to work.
2023-09-23spirv: disable failing testsRobin Voetter
2023-08-11Sema: avoid deleting runtime side-effects in comptime initializersJacob Young
Closes #16744
2023-08-09AstGen: handle `ty` result location for struct and array init correctlymlugg
Well, this was a journey! The original issue I was trying to fix is covered by the new behavior test in array.zig: in essence, `ty` and `coerced_ty` result locations were not correctly propagated. While fixing this, I noticed a similar bug in struct inits: the type was propagated to *fields* fine, but the actual struct init was unnecessarily anonymous, which could lead to unnecessary copies. Note that the behavior test added in struct.zig was already passing - the bug here didn't change any easy-to-test behavior - but I figured I'd add it anyway. This is a little harder than it seems, because the result type may not itself be an array/struct type: it could be an optional / error union wrapper. A new ZIR instruction is introduced to unwrap these. This is also made a little tricky by the fact that it's possible for result types to be unknown at the time of semantic analysis (due to `anytype` parameters), leading to generic poison. In these cases, we must essentially downgrade to an anonymous initialization. Fixing these issues exposed *another* bug, related to type resolution in Sema. That issue is now tracked by #16603. As a temporary workaround for this bug, a few result locations for builtin function operands have been disabled in AstGen. This is technically a breaking change, but it's very minor: I doubt it'll cause any breakage in the wild.
2023-06-28behavior: test slicing array of zero-sized valueszooster
Closes #15343
2023-06-26AstGen: fix result locations for elements of typed array initmlugg
Resolves: #16226
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13all: replace `comptime try` with `try comptime`Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-05-20spirv: more passing testsRobin Voetter
2023-05-13Merge pull request #15643 from Vexu/fixesVeikka Tuominen
make `@call` compile errors match regular calls
2023-05-11setup spirv backend in behavior testsAli Chraghi
2023-05-11fix incorrect use of mutable pointers to temporary valuesVeikka Tuominen
2023-04-28stage2: sparc64: Skip unimplemented testsKoakuma
2023-04-20Sema: allow ptr field access on pointer-to-arraymlugg
Also remove an incorrect piece of logic which allowed fetching the 'len' property on non-single-ptrs (e.g. many-ptrs) and add a corresponding compile error test case. Resolves: #4765
2023-04-13x86_64: fix some of the mass confusion about the meaning of `MCValue`Jacob Young
2023-03-25x86_64: implement atomic loopsJacob Young
2023-03-24x86_64: fix value tracking bugsJacob Young
2023-03-21CBE: implement aggregateInit() for array of array case.Xavier Bouchoux
fixes `error(compilation): clang failed with stderr: error: array type 'uint32_t[10]' (aka 'unsigned int[10]') is not assignable`
2023-03-15disable failing aarch64 backend behavior testsAndrew Kelley
2023-03-15behavior: enable passing behavior tests on stage2_x86_64Jacob Young
2023-03-14Sema: allow comptime mutation of multiple array elementsmlugg
Previously, if you had a pointer to multiple array elements and tried to write to it at comptime, it was incorrectly treated as a pointer to one specific array value, leading to an assertion down the line. If we try to mutate a value at an elem_ptr larger than the element type, we need to perform a modification to multiple array elements. This solution isn't ideal, since it will result in storePtrVal serializing the whole array, modifying the relevant parts, and storing it back. Ideally, it would only take the required elements. However, this change would have been more complex, and this is a fairly rare operation (nobody ever ran into the bug before after all), so it doesn't matter all that much.
2023-02-18update existing behavior tests and std lib to new for loop semanticsAndrew Kelley
2022-12-31add tests for fixed stage1 bugsVeikka Tuominen
Closes #4144 Closes #4255 Closes #4372 Closes #4375 Closes #4380 Closes #4417 Closes #4423 Closes #4476 Closes #4528 Closes #4562 Closes #4572 Closes #4597 Closes #4639 Closes #4672 Closes #4782 Closes #4955 Closes #4984 Closes #4997 Closes #5010 Closes #5114 Closes #5166 Closes #5173 Closes #5276
2022-12-27add behavior test for comptime pointer castingAndrew Kelley
comptime `@ptrCast` a subset of an array, then write through it closes #2444
2022-12-24behavior: disable tests on failing backendsJacob Young
2022-12-24Sema: relax undefined checks for concatJacob Young
Closes #14037
2022-12-24Sema: support concat of tuple and arrayJacob Young
Closes #14041
2022-12-10stage2: sparc64: Skip unimplemented testsKoakuma
2022-12-06remove references to stage1 in behavior testsAndrew Kelley
Good riddance.
2022-11-04Sema: correct condition in validateArrayInitVeikka Tuominen
Closes #13425
2022-10-25cbe: implement global assemblyJacob Young
2022-10-25behavior: enable stage2_c tests that are currently passingJacob Young
Also fix C warnings triggered by these tests.
2022-10-05fix(text): hyphenation and other fixesr00ster91
2022-09-09stage2 ARM: implement basic array_elem_valjoachimschmidt557
2022-09-09stage2 ARM: implement struct_field_val for registersjoachimschmidt557
2022-07-14Sema: fix coerceResultPtrAndrew Kelley
It did not handle properly when the dummy operand was a comptime_int; it was crashing in coerce because comptime_int is supposed to be comptime-known. So when calling coerceResultPtr, we pass the actual operand, not a dummy operand, which means it will have the proper comptime value when necessary.
2022-06-25stage2 ARM: implement basic intCast and error union wrappingjoachimschmidt557
2022-06-24stage2: sparc64: Skip Sema-failing tests for nowKoakuma
2022-06-17Sema: handle sentinels in tupleToArrayVeikka Tuominen
2022-06-03Sema: fix initialization of array with comptime only elem typeVeikka Tuominen
2022-05-27stage2 AArch64: complete genTypedValuejoachimschmidt557