aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/redundant_try.zig
AgeCommit message (Collapse)Author
2025-07-31Sema: add note suggesting dropping try on non error-unionsmikastiv
2025-07-17test: Restore and fix deleted tests that relied on intern pool types (#24422)Felix Koppe
2025-06-07seriously don't put internpool indexes in test casesAndrew Kelley
2025-06-06x86_64: add support for pie executablesJacob Young
2025-05-31Legalize: implement scalarization of binary operationsJacob Young
2025-05-28x86_64: implement integer `@reduce(.Max)`Jacob Young
2025-05-28x86_64: implement integer `@reduce(.Min)`Jacob Young
2025-05-28x86_64: implement optimized float `@reduce(.Mul)`Jacob Young
2025-05-28x86_64: rewrite bitwise `@reduce`Jacob Young
2025-05-21spirv: super basic composite int supportAli Cheraghi
2025-05-20compiler: Scaffold stage2_powerpc backend.Alex Rønne Petersen
Nothing interesting here; literally just the bare minimum so I can work on this on and off in a branch without worrying about merge conflicts in the non-backend code.
2025-05-17x86_64: rewrite `@splat`Jacob Young
2025-05-17x86_64: rewrite vector `+|`Jacob Young
2025-05-03std.Target: Add Cpu.Arch.or1k and basic target info.Alex Rønne Petersen
2025-03-21x86_64: rewrite wrapping multiplicationJacob Young
2025-02-17test: Update some compiler-internal type names in expected output.Alex Rønne Petersen
2025-02-03meta: fix failing test case affecting masterMeghan Denny
2025-02-01compiler: do not propagate result type to `try` operandmlugg
This commit effectively reverts 9e683f0, and hence un-accepts #19777. While nice in theory, this proposal turned out to have a few problems. Firstly, supplying a result type implicitly coerces the operand to this type -- that's the main point of result types! But for `try`, this is actually a bad idea; we want a redundant `try` to be a compile error, not to silently coerce the non-error value to an error union. In practice, this didn't always happen, because the implementation was buggy anyway; but when it did, it was really quite silly. For instance, `try try ... try .{ ... }` was an accepted expression, with the inner initializer being initially coerced to `E!E!...E!T`. Secondly, the result type inference here didn't play nicely with `return`. If you write `return try`, the operand would actually receive a result type of `E!E!T`, since the `return` gave a result type of `E!T` and the `try` wrapped it in *another* error union. More generally, the problem here is that `try` doesn't know when it should or shouldn't nest error unions. This occasionally broke code which looked like it should work. So, this commit prevents `try` from propagating result types through to its operand. A key motivation for the original proposal here was decl literals; so, as a special case, `try .foo(...)` is still an allowed syntax form, caught by AstGen and specially lowered. This does open the doors to allowing other special cases for decl literals in future, such as `.foo(...) catch ...`, but those proposals are for another time. Resolves: #21991 Resolves: #22633