# frontend: fix reference tracking through coerced function bodies · gitcafe/zig

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

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

Visibility: public

Requested revision: 87448654256d334e1d5877736a9747de67b7eedf

Requested commit: 87448654256d334e1d5877736a9747de67b7eedf

Commit: 87448654256d334e1d5877736a9747de67b7eedf

Tree: 6fc66db83d3f69a2bb69006434872955144d73ed

Author: mlugg

Committer: Matthew Lugg

## Message

```
frontend: fix reference tracking through coerced function bodies

This bug was manifesting for user as a nasty link error because they
were calling their application's main entry point as a coerced function,
which essentially broke reference tracking for the entire ZCU, causing
exported symbols to silently not get exported.

I've been a little unsure about how coerced functions should interact
with the unit graph before, but the solution is actually really obvious
now: they shouldn't! `Sema` is now responsible for unwrapping
possibly-coerced functions *before* queuing analysis or marking unit
references. This makes the reference graph optimal (there are no
redundant edges representing coerced versions of the same function) and
simplifies logic elsewhere at the expense of just a few lines in Sema.

```

## Parents

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

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