aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/error.zig
AgeCommit message (Collapse)Author
2022-09-09stage2 ARM: amend implementation of various AIR instructionsjoachimschmidt557
- unwrap_errunion_err for registers - unwrap_errunion_payload for registers - ptr_slice_len_ptr for all MCValues - ptr_slice_ptr_ptr for all MCValues
2022-08-25LLVM: fix missing alignment on wrapping instructionsAndrew Kelley
Previously, when lowering AIR instructions `wrap_errunion_payload`, `wrap_errunion_err`, and `wrap_optional`, the LLVM backend would create an alloca instruction to store the result, but did not set the alignment on it. This caused UB which went undetected for a long time until we started enabling the stack protector. Closes #12594 Unblocks #12508 Inspires #12634 Tests passed locally: * test-behavior * test-cases
2022-08-22Sema: fix parameter of type 'T' must be comptime errorVeikka Tuominen
Closes #12519 Closes #12505
2022-08-17Sema: make noreturn error union behave correctlyVeikka Tuominen
2022-07-22stage2: fix airIsErr when `is_ptr == true`Veikka Tuominen
2022-06-28Revert "AstGen: preserve inferred ptr result loc for breaks"Andrew Kelley
This reverts commit 8bf3e1f8d0902abd4133e2729b3625c25011c3ff, which introduced miscompilations for peer expressions any time they needed coercions to runtime types. I opened #11957 as a proposal to accomplish the goal of the reverted commit. Closes #11898
2022-06-25stage2 ARM: implement basic intCast and error union wrappingjoachimschmidt557
2022-06-11stage2: make `error{}` the same size as `anyerror`Veikka Tuominen
Having `error{}` be a zero bit type causes issues when it interracts with empty inferred error sets which are the same size as `anyerror`.
2022-06-07Sema: allow simple else body even when all errors handledVeikka Tuominen
2022-06-07Sema: make `analyzeIsNonErr` even lazier for inferred error setsVeikka Tuominen
2022-05-27stage2 AArch64: complete genTypedValuejoachimschmidt557
2022-05-24stage2: treat `error{}!void` as a zero-bit typeAndrew Kelley
2022-05-24stage2: fixes for error unions, optionals, errorsAndrew Kelley
* `?E` where E is an error set with only one field now lowers the same as `bool`. * Fix implementation of errUnionErrOffset and errUnionPayloadOffset to properly compute the offset of each field. Also name them the same as the corresponding LLVM functions and have the same function signature, to avoid confusion. This fixes a bug where wasm was passing the error union type instead of the payload type. * Fix C backend handling of optionals with zero-bit payload types. * C backend: separate out airOptionalPayload and airOptionalPayloadPtr which reduces branching and cleans up control flow. * Make Type.isNoReturn return true for error sets with no fields. * Make `?error{}` have only one possible value (null).
2022-05-24stage2 ARM: update to new union layoutjoachimschmidt557
2022-05-24aarch64: update for new error union layoutJakub Konka
2022-05-24x64,arm,aarch64: omit unsupported tests for nowJakub Konka
2022-05-24stage2: make `?anyerror` represented the same as `anyerror`Andrew Kelley
I was able to get the backend implementation working on LLVM and the C backend, but I'm going to ask for some help on the other backends.
2022-05-24wasm: Fixes for error union semanticsLuuk de Gram
2022-05-24stage2: fixes for error union semanticsAndrew Kelley
* Sema: avoid unnecessary safety checks when an error set is empty. * Sema: make zirErrorToInt handle comptime errors that are represented as integers. * Sema: make empty error sets properly integrate with typeHasOnePossibleValue. * Type: correct the ABI alignment and size of error unions which have both zero-bit error set and zero-bit payload. The previous code did not account for the fact that we still need to store a bit for whether there is an error. * LLVM: lower error unions possibly with the payload first or with the error code first, depending on alignment. Previously it always put the error code first and used a padding array. * LLVM: lower functions which have an empty error set as the return type the same as anyerror, so that they can be used where fn()anyerror function pointers are expected. In such functions, Zig will lower ret to returning zero instead of void. As a result, one more behavior test is passing.
2022-05-18Merge pull request #11635 from wsengir/stage2-errsetcast-safetyAndrew Kelley
stage2: `@errSetCast` safety
2022-05-18wasm: enable 128bit integer behavior testsLuuk de Gram
2022-05-11aarch64,arm: disable broken `@errSetCast` testWilliam Sengir
2022-04-02stage2 llvm: properly align error union payloadVeikka Tuominen
2022-03-30Sema: enhance is_non_err to be comptime more oftenAndrew Kelley
* Sema: store the precomputed monomorphed_funcs hash inside Module.Fn. This is important because it may be accessed when resizing monomorphed_funcs while this Fn has already been added to the set, but does not have the owner_decl, comptime_args, or other fields populated yet. * Sema: in `analyzeIsNonErr`, take advantage of the AIR tag being `wrap_errunion_payload` to infer that `is_non_err` is comptime true without performing any error set resolution. - Also add some code to check for empty inferred error sets in this function. If necessary we do resolve the inferred error set. * Sema: queue full type resolution of payload type when `wrap_errunion_payload` AIR instruction is emitted. This ensures the backend may check the alignment of it. * Sema: resolveTypeFully now additionally resolves comptime-only status. closes #11306
2022-03-23wasm: Enable all passing testsLuuk de Gram
All tests have been manually verified which are now passing. This means that any remaining TODO is an actual to-be-fixed or to-be-implemented test case.
2022-03-23stage2 CBE: Improve support for unions and error setsCody Tapscott
This includes various fixes/improvements to the C backend to improve error/union support. It also fixes up our handling of decls, where some decls were not correctly marked alive.
2022-03-22CBE: enable more passing tests (#11258)Daniele Cocca
2022-03-17CBE: enable more tests that are currently passingDaniele Cocca
2022-03-12Sema: always allow coercing error set to current inferred error setVeikka Tuominen
2022-03-12Sema: fix typo in resolvePeerTypesVeikka Tuominen
2022-03-11Sema: fix resolution of inferred error setsAndrew Kelley
Introduce `Module.ensureFuncBodyAnalyzed` and corresponding `Sema` function. This mirrors `ensureDeclAnalyzed` except also waits until the function body has been semantically analyzed, meaning that inferred error sets will have been populated. Resolving error sets can now emit a "unable to resolve inferred error set" error instead of producing an incorrect error set type. Resolving error sets now calls `ensureFuncBodyAnalyzed`. Closes #11046. `coerceInMemoryAllowedErrorSets` now does a lot more work to avoid resolving an inferred error set if possible. Same with `wrapErrorUnionSet`. Inferred error set types no longer check the `func` field to determine if they are equal. That was incorrect because an inline or comptime function call produces a unique error set which has the same `*Module.Fn` value for this field. Instead we use the `*Module.Fn.InferredErrorSet` pointers to test equality of inferred error sets.
2022-03-11stage2: is_non_error always returns comptime true for empty error setMitchell Hashimoto
2022-03-10stage2: improve Type.eql and Type.hash for error setsAndrew Kelley
* Reduce branching in Type.eql and Type.hash for error sets. * `Type.eql` uses element-wise bytes comparison since it can rely on the error sets being pre-sorted. * Avoid unnecessarily skipping tests that are passing.
2022-03-10stage2: error_set_merged type equalityMitchell Hashimoto
This implements type equality for error sets. This is done through element-wise error set comparison. Inferred error sets are always distinct types and other error sets are always sorted. See #11022.
2022-03-09wasm: Enable passing behavior testsLuuk de Gram
This also adds some float-related instructions to MIR/Emit
2022-03-05stage2 AArch64: add more slice supportjoachimschmidt557
* airSlice * airArrayToSlice * and initial support for airSlicePtr and co
2022-03-04stage2 ARM: generate less no-op branchesjoachimschmidt557
The checks detecting such no-op branches (essentially instructions that branch to the instruction immediately following the branch) were tightened to catch more of these occurrences.
2022-03-02stage2: implement @errSetCast (#11039)Mitchell Hashimoto
2022-03-01Merge pull request #11016 from ziglang/x64-more-codegenJakub Konka
2022-02-28Sema: clean up peer resolution of errorsAndrew Kelley
* Fix compile error for `zirErrorUnionType`. * Convert zirMergeErrorSets logic to call `Type.errorSetMerge`. It does not need to create a Decl as the TODO comment hinted. * Extract out a function called `resolveInferredErrorSetTy`. * Rework `resolvePeerTypes` with respect to error unions and error sets. This is a less complex implementation that passes all the same tests and uses many fewer lines of code by taking advantage of the function `coerceInMemoryAllowedErrorSets`. - Always merge error sets in the order that makes sense, even when that means `@typeInfo` incompatibility with stage1. * `Type.errorSetMerge` no longer overallocates. * Don't skip passing tests.
2022-02-28stage2: skip error union test on nativeMitchell Hashimoto
2022-02-28stage2: implement peer type resolution between error unionsMitchell Hashimoto
2022-02-28codegen: fix padding calculation for error unions when loweringJakub Konka
* do not track `rdi` register before `call` inst, but instead freeze it from further use, until `call` has been realised * pass more error union tests
2022-02-28x64: impl unwrap_errunion_payload and unwrap_errunion_err for registerJakub Konka
2022-02-27stage2 ARM: enable more behavior testsjoachimschmidt557
2022-02-26stage2: @TypeInfo for error sets (#10998)Mitchell Hashimoto
2022-02-26stage2: actually coerce in coerce_result_ptr at comptimeVeikka Tuominen
2022-02-22Port more behavior testsJakub Konka
2022-02-12organize behavior testsAndrew Kelley
moving towards disabling failing tests on an individual basis
2022-01-26organize behavior testsAndrew Kelley
check the set of passing tests; move towards the disabling logic being inside each test rather than which files are included. this enables a few more passing tests.