# Sema: Prevent tail calls of std.builtin.returnError\(\)\. · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/7415739e36cf16574b754dda5ce03c0026b6907c)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 7415739e36cf16574b754dda5ce03c0026b6907c

Requested commit: 7415739e36cf16574b754dda5ce03c0026b6907c

Commit: 7415739e36cf16574b754dda5ce03c0026b6907c

Tree: e5a46f37de3cff3df28c4f4c441e1763ee9e7dea

Author: Alex Rønne Petersen

Committer: Alex Rønne Petersen

## Message

```
Sema: Prevent tail calls of std.builtin.returnError().

LLVM 20 started tail-calling it in some of our test cases, resulting in:

    error: AndMyCarIsOutOfGas
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:2:5: 0x103ef9d in main (repro)
        return error.TheSkyIsFalling;
        ^
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:6:5: 0x103efa5 in main (repro)
        return error.AndMyCarIsOutOfGas;
        ^
    /home/alexrp/Source/ziglang/zig-llvm20/lib/std/start.zig:656:37: 0x103ee83 in posixCallMainAndExit (repro)
                const result = root.main() catch |err| {
                                        ^

instead of the expected:

    error: AndMyCarIsOutOfGas
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:2:5: 0x103f00d in main (repro)
        return error.TheSkyIsFalling;
        ^
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:6:5: 0x103f015 in main (repro)
        return error.AndMyCarIsOutOfGas;
        ^
    /home/alexrp/Source/ziglang/zig-llvm20/repro.zig:11:9: 0x103f01d in main (repro)
            try bar();
            ^

```

## Parents

- [82b9d9c0f6adf471543b160e15eaeb2a14c722cb](https://git.cafe/gitcafe/zig/commit/82b9d9c0f6adf471543b160e15eaeb2a14c722cb?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/7415739e36cf16574b754dda5ce03c0026b6907c?format=markdown)
