Skip to content

fix(codegen): store struct literal members with assignment semantics (1.0.x) - #1916

Merged
ghaith merged 2 commits into
release/1.0.xfrom
fix/PRG-4799-1.0.x
Sep 15, 2026
Merged

ghaith merged 2 commits into
release/1.0.xfrom
fix/PRG-4799-1.0.x

Conversation

@ghaith

@ghaith ghaith commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Backport of #1912 to release/1.0.x.

Problem: A struct literal used as a value (array-of-struct initializers, or x := (a := ..., b := ...) in a body) inserted string members with the size of the value instead of the declared member size. The resulting IR is invalid; at -Onone LLVM corrupts the heap while lowering it, so plc crashes or panics at an unrelated place instead of reporting an error.

Solution: Struct literals with runtime member values are now materialized in a stack temporary and every member is written through the regular assignment path, so strings follow the same size rules as any assignment. Literal-only struct literals still fold into a single constant, now with strings sized to the declared member length.

Refs: PRG-4799

🤖 Generated with Claude Code

Problem: A struct literal used as a value (array-of-struct initializers,
or `x := (a := ..., b := ...)` in a body) inserted string members with
the size of the value instead of the declared member size. The IR is
invalid; at `-Onone` LLVM corrupts the heap while lowering it, so `plc`
crashes or panics at an unrelated place instead of reporting an error.

Solution: Struct literals with runtime member values are materialized in
a stack temporary and every member is written through the regular
assignment path, so strings follow the same size rules as any
assignment. Literal-only struct literals still fold into one constant,
now with strings sized to the declared member length.

Refs: PRG-4799

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 05fa1c2)
@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

Build Artifacts

🐧 Linux

Artifact Link Size
deb-aarch64 Download 5.4 MB
stdlib Download 33.5 MB
plc-aarch64 Download 43.3 MB
deb-x86_64 Download 10.9 MB
schema Download 0.0 MB
plc-x86_64 Download 43.5 MB

From workflow run

🪟 Windows

Artifact Link Size
plc.exe Download 38.3 MB
stdlib.dll Download 0.1 MB
stdlib.lib Download 4.0 MB

From workflow run

@ghaith
ghaith requested review from mhasel and volsa September 14, 2026 07:19
@ghaith
ghaith enabled auto-merge (squash) September 15, 2026 07:18
@ghaith
ghaith merged commit 2f33a28 into release/1.0.x Sep 15, 2026
22 of 23 checks passed
@ghaith
ghaith deleted the fix/PRG-4799-1.0.x branch September 15, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants