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

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

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

Visibility: public

Requested revision: 4cfb58342ab40adc1a179bfde9fcb116f47bb9d7

Requested commit: 4cfb58342ab40adc1a179bfde9fcb116f47bb9d7

Commit: 4cfb58342ab40adc1a179bfde9fcb116f47bb9d7

Tree: 07dc857d4d9656ef97f10fa1a89ae8b440f00918

Author: mlugg

Committer: mlugg

## 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

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

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