Repository navigation
Check each project with its own options when imports are cached - #20977
Open
michaelglass wants to merge 6 commits into
Open
michaelglass wants to merge 6 commits into
michaelglass wants to merge 6 commits into
Conversation
…ts are reused The TcGlobals cached with the framework imports was rebuilt for a project only when langVersion, realsig or pathMap differed, and the rebuilt instance copied useReflectionFreeCodeGen, emitDebugInfoInQuotations, noDebugAttributes and isInteractive from the project that filled the cache. The background and the transparent compiler each had their own copy of that comparison and of the TcGlobals construction. Both now call one function, TcGlobalsForTcConfig, which reuses the cached TcGlobals only when it carries all of the project's options and otherwise builds one from its framework values and the project's TcConfig. That construction is also the one BuildFrameworkTcImports uses, so an option added to TcGlobals later is taken from TcConfig in one place. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
✅ Release notes checked
|
michaelglass
marked this pull request as draft
November 14, 2026 07:15
Also name the script resolution rules, which the fix covers. Co-Authored-By: Claude Fable 5.2 <[email protected]>
TcGlobals took nine TcConfig options as separate constructor arguments, and TcGlobalsForTcConfig decided whether a cached TcGlobals could be reused by comparing eight of them by hand. An option added to TcGlobals later would be missed by that comparison unless someone remembered to extend it. The options are now one record, TcGlobalsOptions, which TcGlobals takes as a single argument and exposes as g.options. tcGlobalsOptionsOf builds it from TcConfig, and reuse is g.options = tcGlobalsOptionsOf tcConfig. A record expression must assign every field and record equality compares every field, so a new option cannot be built without taking it from TcConfig, nor left out of the comparison. checkNullness is now compared too, so the comment excusing it is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015vTs7XwyE4i4iEpQis6Sad
Co-Authored-By: Claude Fable 5.2 <[email protected]>
michaelglass
marked this pull request as ready for review
November 14, 2026 07:51
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This branch has not been deployed
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
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.
Description
Before this PR
TcGlobals, and it carries the compiler options of whichever project was checked first:--reflectionfree,--quotations-debug,--nodebugdata, and its script resolution rules. A project that references another in memory is checked wrongly even on a fresh checker:Library is type-checked with App's
--reflectionfree, so its%Afails format checking andsrecovers asobj. Between unrelated projects on one checker, a project without the option reports the%Aerror when a--reflectionfreeproject was checked before it, and in the other order the--reflectionfreeproject loses that error.After this PR
TcGlobalstakes every option it reads fromTcConfigas one record,TcGlobalsOptions, built by one function. Both compilers reuse the cached instance only when its record equals the project's, and otherwise build one from the cached framework values. An option added later is a new record field, so it is compared without anyone having to remember a list.Regression tests:
ReflectionFree.fsandScriptResolutionRules.fsintests/FSharp.Compiler.ComponentTests/FSharpChecker/.Related: this extends #20476, which fixed #20474. That PR fixed the same sharing for
--pathmapby rebuilding the cachedTcGlobalswhen a project's path map differs from the cached one. The other options were still copied from the cached instance; the path map is now one field of the same record.Checklist