Fix compiler crash when passing an array literal to OutStream.writev#5192
Open
SeanTAllen wants to merge 1 commit intomainfrom
Open
Fix compiler crash when passing an array literal to OutStream.writev#5192SeanTAllen wants to merge 1 commit intomainfrom
OutStream.writev#5192SeanTAllen wants to merge 1 commit intomainfrom
Conversation
`detect_values_element_type` in the array literal element-type inference only stripped a top-level `this->` arrow from the element type extracted from an interface's `values()` method. When the element type came from a type alias that expanded into a union (such as `ByteSeq = (String | Array[U8] val)` in `ByteSeqIter`), the viewpoint pass distributed the `this->` across the union members. The top-level check then saw a `TK_UNIONTYPE` and left the arrows in place. The unstripped arrows reached code generation and tripped an assertion in `type_append` at `codegen/genname.c`. `detect_apply_element_type` already used the recursive `strip_this_arrow` helper for the same reason. The values-based strategy now does too, bringing the two paths into parity. Closes #2701 Closes #2790
db29111 to
3d5e261
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2701 (and the duplicate #2790).
detect_values_element_typepreviously only stripped a top-levelthis->arrow from the inferred element type. When the element type came from a type alias that expanded into a union (likeByteSeq = (String | Array[U8] val)inByteSeqIter), the viewpoint pass distributed thethis->across the union members, so the top-level check saw aTK_UNIONTYPEand left the arrows inside. Those arrows reached code generation and tripped the assertion atcodegen/genname.c:63.The fix delegates to the existing
strip_this_arrowhelper, which already recurses through union/intersection/tuple.detect_apply_element_typehas been using it for the same reason — the values path is now in parity with the apply path.A second full-program test was added in a follow-up commit with a locally-declared interface and type alias, so the regression is pinned to the shape that triggered the crash rather than to the stdlib's
ByteSeqIter/ByteSeqdefinitions.