aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/switch.zig
AgeCommit message (Collapse)Author
2025-08-07address commentsJustus Klausecker
2025-08-07Add support for both '_' and 'else' prongs at the same time in switch statementsJustus Klausecker
If both are used, 'else' handles named members and '_' handles unnamed members. In this case the 'else' prong will be unrolled to an explicit case containing all remaining named values.
2025-08-07Permit explicit tags with '_' switch prongJustus Klausecker
Mainly affects ZIR representation of switch_block[_ref] and special prong (detection) logic for switch. Adds a new SpecialProng tag 'absorbing_under' that allows specifying additional explicit tags in a '_' prong which are respected when checking that every value is handled during semantic analysis but are not transformed into AIR and instead 'absorbed' by the '_' branch.
2025-07-28aarch64: workaround some optional/union issuesJacob Young
2025-07-27Merge pull request #24585 from jacobly0/aarch64Andrew Kelley
aarch64: more progress
2025-07-26aarch64: implement more optional/error union/union supportJacob Young
2025-07-26aarch64: implement complex switch prongsJacob Young
2025-07-26x86_64: fix switch on mod resultJacob Young
Closes #24541
2025-07-22aarch64: add new from scratch self-hosted backendJacob Young
2025-06-16rename spirv backend nameAli Cheraghi
`stage2_spirv64` -> `stage2_spirv`
2025-06-06x86_64: fix switch dispatch bugJacob Young
Also closes #23902
2025-04-09x86_64: fix switch on big intsJacob Young
2025-02-24test: skip failing tests with spirv-vulkanAli Cheraghi
2025-02-22stage2-wasm: implement switch_dispatch + handle > 32 bit integers in switchesPavel Verigo
Updated solution is future proof for arbitary size integer handling for both strategies .br_table lowering if switch case is dense, .br_if base jump table if values are too sparse.
2024-10-13spirv: skip range switch testsRobin Voetter
This is not yet implemented
2024-09-12AstGen: do not allow unlabeled `break` to exit a labeled switchmlugg
`break`ing from something which isn't a loop should always be opt-in. This was a bug in #21257.
2024-09-01AstGen: allow breaking from labeled switchmlugg
Also, don't use the special switch lowering for errors if the switch is labeled; this isn't currently supported. Related: #20627.
2024-07-26riscv: update tests and fix reuse bugDavid Rubin
2024-07-26riscv: clean up and unify encoding logicDavid Rubin
2024-07-26riscv: implement more operatorsDavid Rubin
we can run `std.debug.print` now, with both run-time strings and integers!
2024-07-14riscv: truncate `airStructFieldVal` resultDavid Rubin
2024-06-13riscv: rewrite "binOp"David Rubin
Reorganize how the binOp and genBinOp functions work. I've spent quite a while here reading exactly through the spec and so many tests are enabled because of several critical issues the old design had. There are some regressions that will take a long time to figure out individually so I will ignore them for now, and pray they get fixed by themselves. When we're closer to 100% passing is when I will start diving into them one-by-one.
2024-06-13riscv: fix register clobber in certain edge casesDavid Rubin
2024-06-13ZigObject: enforce min function alignement on riscvDavid Rubin
2024-06-13riscv: `std.fmt.format` runningDavid Rubin
- implements `airSlice`, `airBitAnd`, `airBitOr`, `airShr`. - got a basic design going for the `airErrorName` but for some reason it simply returns empty bytes. will investigate further. - only generating `.got.zig` entries when not compiling an object or shared library - reduced the total amount of ops a mnemonic can have to 3, simplifying the logic
2024-06-13riscv: switch progress + by-ref return progressDavid Rubin
2024-05-11riscv: add stage2_riscv to test matrix and bypass failing testsDavid Rubin
2024-04-06spirv: enable passing testsRobin Voetter
2024-04-06spirv: implement `@divFloor`, `@floor` and `@mod`Ali Chraghi
2024-03-08Sema: reset block error return trace index between casesmlugg
Resolves: #19210
2024-03-02Air: replace `.dbg_inline_*` with `.dbg_inline_block`Jacob Young
This prevents the possibility of not emitting a `.dbg_inline_end` instruction and reduces the allocation requirements of the backends. Closes #19093
2024-02-08Polish a few tests in switch.zigJohn Schmidt
- Return `error.TestFailed` instead of panicing - Use `comptime assert` for type checks so that errors surface at compile time
2024-02-08Improvements after code reviewJohn Schmidt
2024-02-08Preserve field alignment in union pointer capturesJohn Schmidt
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-28Sema: do not assume switch item indices align with union field indicesmlugg
Resolves: #17754
2023-10-18spirv: switch on boolAli Chraghi
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-09-23spirv: enable passing testsRobin Voetter
2023-09-23spirv: disable failing testsRobin Voetter
2023-07-26add behavior test for switch nested breakAndrew Kelley
closes #10196
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-23sema: Fix overflow when analyzing an inline switch prong range that ends on ↵kcbanner
the maximum value of the switched type
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-06-13Sema: resolve union payload switch captures with peer type resolutionmlugg
This is a bit harder than it seems at first glance. Actually resolving the type is the easy part: the interesting thing is actually getting the capture value. We split this into three cases: * If all payload types are the same (as is required in status quo), we can just do what we already do: get the first field value. * If all payloads are in-memory coercible to the resolved type, we still fetch the first field, but we also emit a `bitcast` to convert to the resolved type. * Otherwise, we need to handle each case separately. We emit a nested `switch_br` which, for each possible case, gets the corresponding union field, and coerces it to the resolved type. As an optimization, the inner switch's 'else' prong is used for any peer which is in-memory coercible to the target type, and the bitcast approach described above is used. Pointer captures have the additional constraint that all payload types must be in-memory coercible to the resolved type. Resolves: #2812
2023-05-20spirv: ptr_elem_valRobin Voetter
Implements the ptr_elem_val air tag. Implementation is unified with ptr_elem_ptr.
2023-05-20spirv: more passing testsRobin Voetter