Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 16, 2025

Implementation Status - Debugging Complete, Baselines Updated

Working on completing the --disableLanguageFeature CLI switch implementation.

Recent Changes:

  • Updated FSI help baselines (help40.437.1033.bsl, help40-nologo.437.1033.bsl)
  • Confirmed cache key handling works correctly (OtherOptions comparison)
  • All unit tests passing (6/6)

Changes Made:

  • Added TryParseFeature method using reflection with proper binding flags
  • Added disabledLanguageFeatures field to TcConfigBuilder as Set
  • Modified LanguageVersion.SupportsFeature to check disabled features
  • Added WithDisabledFeatures method for copy-and-update pattern (immutable design)
  • Added --disableLanguageFeature CLI option (repeatable)
  • Added DisabledLanguageFeatures MSBuild property
  • Added error handling for invalid feature names (error 3879)
  • Updated help test baselines (FSC and FSI)
  • Created comprehensive unit tests using typecheck with exact error assertions
  • Applied code formatting
  • Updated release notes
  • Updated repository-level copilot instructions

Test Results:

Ran 6 tests: 6 passed, 0 failed
Duration: 4 seconds

Cache Key Analysis:

FSharpProjectOptions cache keys already handle disabled features correctly because AreSameForChecking compares OtherOptions arrays (line 180 in FSharpCheckerResults.fs), and --disableLanguageFeature:Feature is passed via OtherOptions. No additional cache key changes needed.

Next Steps:

  • Run fantomas formatting
  • Final verification of all tests
  • Code review
Original prompt

Motivation:
Enable a way to selectively disable specific F# language features on a per-project basis by providing a repeatable command line switch, even when the language version would otherwise enable the feature. This is useful for regression-testing, troubleshooting, or as an off-switch for problematic or experimental features.

Scope:

  • A repeatable CLI argument is added: --disableLanguageFeature:
  • For every entry, parse the argument to the LanguageFeature DU. Validate (fail with an error listing valid feature names if not present).
  • Temporarily collect/hold the array of disabled features during CLI/config processing until LanguageVersion is constructed.
  • Pass the array into LanguageVersion at all construction sites.
  • LanguageVersion stores the array and updates SupportsFeature: it returns false if the feature is listed in the disables array, regardless of language version.
  • Use Array.contains for the disables check. No Sets/Lists/Dicts are needed.
  • All feature-gating through SupportsFeature: no callsite changes.
  • Add help text for the new CLI switch (FSComp.txt and in CompilerOptions).
  • Add a negative ComponentTest for a previously positive feature, showing that disabling the feature (e.g. WhileBang) causes a compile error even in preview mode.
  • Rerun and update CLI/help output tests (e.g., fsc-help.txt) as needed.

Paths to touch:

  • src/Compiler/Driver/CompilerOptions.fs
  • src/Compiler/Facilities/LanguageFeatures.fs
  • src/Compiler/Facilities/LanguageFeatures.fsi
  • src/fsharp/FSharp.Compiler.Interactive.Settings/FSComp.txt
  • tests/FSharp.Compiler.ComponentTests/Language/WhileBangTests.fs
  • tests/fsharp/**/fsc-help.txt (and/or similar help output checks)

Constraints:

  • No significant churn or callsite changes; only extend existing flow.
  • Disabled feature array only lives outside LanguageVersion as a temporary transport.
  • Error diagnostics for invalid feature names must be user-friendly, with a list of valid LanguageFeature options.
  • Test must be minimal; reuse existing test files, just add one negative case for disables.
  • Keep the implementation idiomatic and minimal.

This pull request was created as a result of the following prompt from Copilot chat.

Motivation:
Enable a way to selectively disable specific F# language features on a per-project basis by providing a repeatable command line switch, even when the language version would otherwise enable the feature. This is useful for regression-testing, troubleshooting, or as an off-switch for problematic or experimental features.

Scope:

  • A repeatable CLI argument is added: --disableLanguageFeature:
  • For every entry, parse the argument to the LanguageFeature DU. Validate (fail with an error listing valid feature names if not present).
  • Temporarily collect/hold the array of disabled features during CLI/config processing until LanguageVersion is constructed.
  • Pass the array into LanguageVersion at all construction sites.
  • LanguageVersion stores the array and updates SupportsFeature: it returns false if the feature is listed in the disables array, regardless of language version.
  • Use Array.contains for the disables check. No Sets/Lists/Dicts are needed.
  • All feature-gating through SupportsFeature: no callsite changes.
  • Add help text for the new CLI switch (FSComp.txt and in CompilerOptions).
  • Add a negative ComponentTest for a previously positive feature, showing that disabling the feature (e.g. WhileBang) causes a compile error even in preview mode.
  • Rerun and update CLI/help output tests (e.g., fsc-help.txt) as needed.

Paths to touch:

  • src/Compiler/Driver/CompilerOptions.fs
  • src/Compiler/Facilities/LanguageFeatures.fs
  • src/Compiler/Facilities/LanguageFeatures.fsi
  • src/fsharp/FSharp.Compiler.Interactive.Settings/FSComp.txt
  • tests/FSharp.Compiler.ComponentTests/Language/WhileBangTests.fs
  • tests/fsharp/**/fsc-help.txt (and/or similar help output checks)

Constraints:

  • No significant churn or callsite changes; only extend existing flow.
  • Disabled feature array only lives outside LanguageVersion as a temporary transport.
  • Error diagnostics for invalid feature names must be user-friendly, with a list of valid LanguageFeature options.
  • Test must be minimal; reuse existing test files, just add one negative case for disables.
  • Keep the implementation idiomatic and minimal.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 16, 2025 13:01
- Added TryParseFeature method to LanguageVersion to parse feature names from strings
- Added disabledLanguageFeatures field to TcConfigBuilder to store disabled features
- Added SupportsFeature method to TcConfigBuilder that checks both langVersion and disabled features
- Added --disableLanguageFeature CLI option in CompilerOptions (repeatable)
- Added error message for unrecognized feature names (error 3879)
- Created comprehensive tests for the new functionality

Co-authored-by: T-Gro <[email protected]>
- Applied fantomas formatting to modified files
- Added release notes entry for the new --disableLanguageFeature CLI switch

Co-authored-by: T-Gro <[email protected]>
- Modified LanguageVersion to hold disabled features and check them in SupportsFeature
- Added SetDisabledFeatures method to LanguageVersion
- Updated both langversion and disableLanguageFeature options to call SetDisabledFeatures
- This ensures disabled features are respected regardless of option order
- Applied code formatting

Co-authored-by: T-Gro <[email protected]>
Copilot AI changed the title [WIP] Add command line argument to disable F# language features Add --disableLanguageFeature CLI switch to selectively disable language features Dec 16, 2025
Copilot AI requested a review from T-Gro December 16, 2025 13:22
Copy link
Member

@T-Gro T-Gro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot : Read all comments

@github-project-automation github-project-automation bot moved this from New to In Progress in F# Compiler and Tooling Dec 16, 2025
As requested, removed the SupportsFeature method from TcConfigBuilder since it's not used anywhere and is redundant - callers can directly use langVersion.SupportsFeature()

Co-authored-by: T-Gro <[email protected]>
…re parsing

- Changed LanguageVersion to use immutable array of disabled features instead of mutable set
- Added optional constructor parameter for disabled features array
- Added WithDisabledFeatures method that returns a new LanguageVersion instance
- Replaced manual feature name mapping with reflection-based TryParseFeature using BindingFlags.NonPublic
- Updated CompilerOptions to use immutable pattern with Array.append
- Changed disabledLanguageFeatures in TcConfigBuilder from Set to array
- Updated tests to use typecheck instead of compile and assert exact error codes
- Applied code formatting

Addresses feedback from @T-Gro about making the design immutable and using reflection.

Co-authored-by: T-Gro <[email protected]>
Copilot AI and others added 3 commits December 17, 2025 16:59
- Added null check in TryParseFeature using Option.bind before downcasting
- Changed disabledLanguageFeatures from array to Set in CompilerConfig (better semantics)
- Updated CompilerOptions to use Set.add and convert to array when calling WithDisabledFeatures
- Applied code formatting

Addresses comments from @T-Gro about null handling and using Set in the builder.

Co-authored-by: T-Gro <[email protected]>
Updated compiler_help_output.bsl to include the new --disableLanguageFeature CLI option in help output.

Addresses comment from @T-Gro about updating help tests.

Co-authored-by: T-Gro <[email protected]>
- Added disabledLanguageFeatures field to Fsc task
- Added DisabledLanguageFeatures property (takes ITaskItem array)
- Updated command line builder to pass each feature with --disableLanguageFeature flag
- Follows same pattern as other MSBuild properties

This allows .fsproj files to use:
<DisabledLanguageFeatures>NameOf;StringInterpolation</DisabledLanguageFeatures>

Partial implementation of comment 2627788945 from @T-Gro. Still need to update .targets files.

Co-authored-by: T-Gro <[email protected]>
Copilot AI changed the title Add --disableLanguageFeature CLI switch to selectively disable language features Add --disableLanguageFeature CLI switch and MSBuild property to selectively disable language features Dec 17, 2025
Copilot AI requested a review from T-Gro December 17, 2025 17:10
@T-Gro
Copy link
Member

T-Gro commented Jan 14, 2026

/run ilverify

@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@dotnet dotnet deleted a comment from Copilot AI Jan 14, 2026
@github-actions
Copy link
Contributor

🔧 CLI Command Report

  • Command: /run ilverify
  • Outcome: success

✅ Command succeeded, no changes needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants