Skip to content

fix: resolve generic TO_STRING/TO_WSTRING to the correct monomorphization (#1805) - #1829

Merged
Angus-Bethke-Bachmann merged 2 commits into
release/1.0.xfrom
backport/1.0.x/to-string-monomorph
Aug 3, 2026
Merged

fix: resolve generic TO_STRING/TO_WSTRING to the correct monomorphization (#1805)#1829
Angus-Bethke-Bachmann merged 2 commits into
release/1.0.xfrom
backport/1.0.x/to-string-monomorph

Conversation

@ghaith

@ghaith ghaith commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Backport of #1805 to release/1.0.x (clean cherry-pick of 0212611).

A generic TO_STRING/TO_WSTRING call whose concrete monomorphization was not declared silently re-resolved to <fn>__STRING and reinterpreted the argument's bytes, reading out of bounds at runtime. The call operator is now reset to the resolved monomorphization name, so a missing monomorphization surfaces as an E048 unresolved-reference error at compile time. Also ships the TO_STRING__<T> / TO_WSTRING__<T> monomorphizations for the types that already provide a typed <T>_TO_STRING / <T>_TO_WSTRING conversion.

Verified on this branch: full unit test suite and full lit suite pass, including the two new to_string end-to-end tests.

🤖 Generated with Claude Code

…tion (#1805)

When lowering a call to an aggregate-returning generic function, the
lowerer reset the call operator to the bare generic name and relied on
re-annotation to re-resolve it. For a call whose concrete
monomorphization did not exist, that re-resolution ran against the
injected aggregate return buffer and bound the call to `<fn>__STRING`,
reinterpreting the argument's bytes as a string. For values without an
early null byte this read out of bounds and aborted at runtime.

Reset the operator to the resolved monomorphization name instead. A
generic call whose monomorphization is not declared is now an E048
unresolved-reference error at compile time, consistent with how scalar
generics already surface a missing implementation.

Also add the TO_STRING__<T> / TO_WSTRING__<T> monomorphizations for the
scalar, bit-string, real and date/time types that already ship a typed
<T>_TO_STRING / <T>_TO_WSTRING conversion, so TO_STRING/TO_WSTRING work
for them.

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Angus-Bethke-Bachmann <angus.bethke@bachmann.info>
(cherry picked from commit 0212611)
@ghaith
ghaith requested a review from mhasel July 28, 2026 06:08
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

Build Artifacts

🐧 Linux

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

From workflow run

🪟 Windows

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

From workflow run

@Angus-Bethke-Bachmann
Angus-Bethke-Bachmann enabled auto-merge (squash) August 3, 2026 08:08
@Angus-Bethke-Bachmann
Angus-Bethke-Bachmann merged commit 38834dc into release/1.0.x Aug 3, 2026
23 checks passed
@Angus-Bethke-Bachmann
Angus-Bethke-Bachmann deleted the backport/1.0.x/to-string-monomorph branch August 3, 2026 08:31
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.

3 participants