# Sema: refactor generic calls to interleave argument analysis and parameter type resolution · gitcafe/zig

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

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

Visibility: public

Requested revision: f2c8fa769a92eb61c13f2cc0f75c526c8fd729a9

Requested commit: f2c8fa769a92eb61c13f2cc0f75c526c8fd729a9

Commit: f2c8fa769a92eb61c13f2cc0f75c526c8fd729a9

Tree: 37f611ef1bd700533987eec239667815a491df6d

Author: mlugg

Committer: mlugg

## Message

```
Sema: refactor generic calls to interleave argument analysis and parameter type resolution

AstGen provides all function call arguments with a result location,
referenced through the call instruction index. The idea is that this
should be the parameter type, but for `anytype` parameters, we use
generic poison, which is required to be handled correctly.

Previously, generic instantiations and inline calls worked by evaluating
all args in advance, before resolving generic parameter types. This
means any generic parameter (not just `anytype` ones) had generic poison
result types. This caused missing result locations in some cases.

Additionally, the generic instantiation logic caused `zirParam` to
analyze the argument types a second time before coercion. This meant
that for nominal types (struct/enum/etc), a *new* type was created,
distinct to the result type which was previously forwarded to the
argument expression.

This commit fixes both of these issues. Generic parameter type
resolution is now interleaved with argument analysis, so that we don't
have unnecessary generic poison types, and generic instantiation logic
now handles parameters itself rather than falling through to the
standard zirParam logic, so avoids duplicating the types.

Resolves: #16566
Resolves: #16258
Resolves: #16753

```

## Parents

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

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