diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2023-07-29 06:03:51 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2023-08-09 19:46:55 +0100 |
| commit | 6917a8c25824d12f00327171b583d6cd9a830c29 (patch) | |
| tree | 63b51fef7ea792e31c4cb14fdd732f632e62b03b /lib/std/Build/Step/ConfigHeader.zig | |
| parent | 0461a64a93f0596e98b62d596bb547e5455577d2 (diff) | |
| download | zig-6917a8c25824d12f00327171b583d6cd9a830c29.tar.gz zig-6917a8c25824d12f00327171b583d6cd9a830c29.zip | |
AstGen: handle `ty` result location for struct and array init correctly
Well, this was a journey!
The original issue I was trying to fix is covered by the new behavior
test in array.zig: in essence, `ty` and `coerced_ty` result locations
were not correctly propagated.
While fixing this, I noticed a similar bug in struct inits: the type was
propagated to *fields* fine, but the actual struct init was
unnecessarily anonymous, which could lead to unnecessary copies. Note
that the behavior test added in struct.zig was already passing - the bug
here didn't change any easy-to-test behavior - but I figured I'd add it
anyway.
This is a little harder than it seems, because the result type may not
itself be an array/struct type: it could be an optional / error union
wrapper. A new ZIR instruction is introduced to unwrap these.
This is also made a little tricky by the fact that it's possible for
result types to be unknown at the time of semantic analysis (due to
`anytype` parameters), leading to generic poison. In these cases, we
must essentially downgrade to an anonymous initialization.
Fixing these issues exposed *another* bug, related to type resolution in
Sema. That issue is now tracked by #16603. As a temporary workaround for
this bug, a few result locations for builtin function operands have been
disabled in AstGen. This is technically a breaking change, but it's very
minor: I doubt it'll cause any breakage in the wild.
Diffstat (limited to 'lib/std/Build/Step/ConfigHeader.zig')
0 files changed, 0 insertions, 0 deletions
