-
Notifications
You must be signed in to change notification settings - Fork 833
Fix FS2014 duplicate .cctor error by renaming and delegating static constructors #18801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
T-Gro
merged 11 commits into
main
from
copilot/fix-3269fd31-514e-486d-924d-1ed90880afed
Sep 19, 2025
Merged
Fix FS2014 duplicate .cctor error by renaming and delegating static constructors #18801
T-Gro
merged 11 commits into
main
from
copilot/fix-3269fd31-514e-486d-924d-1ed90880afed
Sep 19, 2025
Conversation
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
Co-authored-by: T-Gro <[email protected]>
Co-authored-by: T-Gro <[email protected]>
Copilot
AI
changed the title
[WIP] Merge duplicate .cctor methods for DUs with generic statics and ensure single static constructor
Fix FS2014 duplicate .cctor error for discriminated unions with generic statics
Jul 31, 2025
Copilot finished work on behalf of
T-Gro
July 31, 2025 10:31
T-Gro
requested changes
Jul 31, 2025
Co-authored-by: T-Gro <[email protected]>
Co-authored-by: T-Gro <[email protected]>
Copilot
AI
changed the title
Fix FS2014 duplicate .cctor error for discriminated unions with generic statics
Fix FS2014 duplicate .cctor error by renaming and delegating static constructors
Jul 31, 2025
Copilot finished work on behalf of
T-Gro
July 31, 2025 15:29
Co-authored-by: T-Gro <[email protected]>
Copilot finished work on behalf of
T-Gro
August 4, 2025 10:51
T-Gro
reviewed
Sep 8, 2025
Co-authored-by: T-Gro <[email protected]>
Copilot finished work on behalf of
T-Gro
September 8, 2025 15:06
|
/run fantomas |
❗ Release notes required
Warning No PR link found in some release notes, please consider adding it.
|
🔧 CLI Command Report
✅ Patch applied: |
T-Gro
approved these changes
Sep 19, 2025
T-Gro
reviewed
Sep 19, 2025
tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/DuplicateCctorFix.fs
Outdated
Show resolved
Hide resolved
Co-authored-by: T-Gro <[email protected]>
auto-merge was automatically disabled
September 19, 2025 10:26
Head branch was pushed to by a user without write access
Done. Applied fantomas formatting in commit 063261c. |
Copilot stopped work on behalf of
T-Gro due to an error
September 19, 2025 10:27
abonie
approved these changes
Sep 19, 2025
This was referenced Oct 14, 2025
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.
Problem Resolved
Fixed discriminated unions with both static members and nullary cases failing compilation with "FS2014: duplicate entry '.cctor' in method table". The solution renames duplicate .cctor methods to unique static methods and creates a single .cctor that calls both, preserving all initialization semantics while ensuring only one .cctor exists in the final IL.
Changes Made
cdef_cctorCode2CodeOrCreatefunction to detect and rename duplicate .cctor methodscctor_renamed_0,cctor_renamed_1) to avoid hardcoded assumptionsrtspecialnamethat delegates to renamed methodsThis pull request was created as a result of the following prompt from Copilot chat.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.