Skip to content

Fix UoM ToString codegen with checknulls#19440

Merged
T-Gro merged 4 commits intomainfrom
bugfix/uom-codegen
Mar 16, 2026
Merged

Fix UoM ToString codegen with checknulls#19440
T-Gro merged 4 commits intomainfrom
bugfix/uom-codegen

Conversation

@T-Gro
Copy link
Member

@T-Gro T-Gro commented Mar 16, 2026

Fix double address-taking in BuildMethodCall for UoM value types, which caused ToString() to return garbage when --checknulls+ was enabled.

Fixes #19435

T-Gro and others added 3 commits March 16, 2026 11:50
The MethInfoWithModifiedReturnType case in BuildMethodCall was recursively
calling BuildMethodCall, which re-invoked TakeObjAddrForMethodCall on
already-addressed object arguments. This created double-indirection
(byref<byref<int>>) for value types, causing ToString() on UoM value
types to return garbage when --checknulls+ was enabled.

Fix: directly call BuildILMethInfoCall with the already-processed allArgs
and valUseFlags, skipping the redundant TakeObjAddrForMethodCall.

Added runtime tests verifying ToString on int and float UoM types
produces correct output with --checknulls+.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Combine two separate [<Fact>] tests into a single [<Theory>] with
[<InlineData>] matching the adjacent test pattern. Add decimal coverage.
Simplify embedded source to print x.ToString() directly and verify
with withStdOutContains instead of embedded validation logic.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use nested pattern MethInfoWithModifiedReturnType(ILMeth(...), retTy) to
directly match the only inner method kind that is ever constructed,
eliminating the duplicated FSMeth branch that could never be reached.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 16, 2026

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.100.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro T-Gro force-pushed the bugfix/uom-codegen branch from df4265a to 5f988ba Compare March 16, 2026 16:41
@github-project-automation github-project-automation bot moved this from New to In Progress in F# Compiler and Tooling Mar 16, 2026
@T-Gro T-Gro enabled auto-merge (squash) March 16, 2026 17:36
@T-Gro T-Gro merged commit 67a56a4 into main Mar 16, 2026
45 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in F# Compiler and Tooling Mar 16, 2026
@T-Gro T-Gro deleted the bugfix/uom-codegen branch March 17, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

UoM ToString returns random values

2 participants