# Sema: avoid error return traces when possible · gitcafe/zig

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

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

Visibility: public

Requested revision: 1a500b969943dc6a4c549fdcbd72659702e867a2

Requested commit: 1a500b969943dc6a4c549fdcbd72659702e867a2

Commit: 1a500b969943dc6a4c549fdcbd72659702e867a2

Tree: b65d3f11b30e1c43f0a63636fe908929e83b0c27

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
Sema: avoid error return traces when possible

stage2 was adding bogus error return trace frames when an error was not
being returned. This commit makes several improvements:

 * Make a runtime check if necessary to only emit a frame into the error
   return trace when an actual error is returned.
 * Use the `analyzeIsNonErrComptimeOnly` machinery to avoid runtime
   checks when it is compile-time-known that the value is an error, or a
   non-error.
 * Make std.builtin.returnError take a non-optional stack trace pointer.

closes #12174

```

## Parents

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

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