Skip to content

Fix compiler crash when passing an array literal to OutStream.writev#5192

Open
SeanTAllen wants to merge 1 commit intomainfrom
fix-issue-2701-array-infer-values-type-alias
Open

Fix compiler crash when passing an array literal to OutStream.writev#5192
SeanTAllen wants to merge 1 commit intomainfrom
fix-issue-2701-array-infer-values-type-alias

Conversation

@SeanTAllen
Copy link
Copy Markdown
Member

@SeanTAllen SeanTAllen commented Apr 8, 2026

Closes #2701 (and the duplicate #2790).

detect_values_element_type previously only stripped a top-level this-> arrow from the inferred element type. When the element type came from a type alias that expanded into a union (like ByteSeq = (String | Array[U8] val) in ByteSeqIter), the viewpoint pass distributed the this-> across the union members, so the top-level check saw a TK_UNIONTYPE and left the arrows inside. Those arrows reached code generation and tripped the assertion at codegen/genname.c:63.

The fix delegates to the existing strip_this_arrow helper, which already recurses through union/intersection/tuple. detect_apply_element_type has 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/ByteSeq definitions.

@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Apr 8, 2026
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Apr 8, 2026
`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
@SeanTAllen SeanTAllen force-pushed the fix-issue-2701-array-infer-values-type-alias branch from db29111 to 3d5e261 Compare April 9, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge discuss during sync Should be discussed during an upcoming sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StdStream.writev with "deep" array literal inference causes compiler crash

2 participants