stage2: correct comptime-known inferred alloc type, plus comptime array init sentinels #11090
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Two changes in here, both needed to get the tests passing in this PR.
At least 3 more passing tests!
For inferred allocs with values known at comptime but not forced comptime (i.e. not in a
comptime {}block), we were setting the incorrect type, causing cascading errors. We can now set the type to the bitcast type. The previous comment noted we can't do that due to constness, but @Vexu's recentmake_const_ptrwork fixes this.A mistake from my prior PR on sentinel array initialization, I was not adding the sentinel to the end of the array value for comptime. Bonus: this solidifies that adding the sentinel as the final op in the
array_init_sentZIR is correct.Tests used during debugging/development are below. First two are the inferred alloc commit, last one is the sentinel bug. The real behavior tests exercise both at once.