Fix panic when creating list literal in polymorphic for loop #8905
+61
−2
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.
This fixes a panic ("reached unreachable code") that occurred when creating a list literal inside a for loop over a polymorphic list parameter.
The bug happened because when a polymorphic function contains a for loop that iterates over a polymorphic list parameter and creates a new list literal from the loop element (e.g.,
[e]), the interpreter expected the list's compile-time type to be a concreteList(elem)structure. However, in polymorphic contexts, the list type was a flex variable, causing an assertion failure.e_listhandling to get element type from the first element's compile-time type when the list type is not a structuretest/fx/issue8898.rocwith corresponding test infx_platform_test.zigFixes #8898
Co-authored by Claude Opus 4.5