Skip to content

Honor --nowarn for command-line option warnings#19776

Merged
abonie merged 11 commits into
mainfrom
fix/nowarn-75
May 21, 2026
Merged

Honor --nowarn for command-line option warnings#19776
abonie merged 11 commits into
mainfrom
fix/nowarn-75

Conversation

@T-Gro
Copy link
Copy Markdown
Member

@T-Gro T-Gro commented May 20, 2026

Fixes #19576

--nowarn and --warnaserror are now applied to warnings emitted during command-line option parsing, matching their behavior for all other compiler warnings.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 20, 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

@T-Gro T-Gro added AI-Auto-Resolve-CI Opt-in: LabelOps triages CI failures on this PR every 3h AI-Auto-Resolve-Conflicts Opt-in: LabelOps merges main into this PR and resolves conflicts every 3h labels May 20, 2026
@T-Gro T-Gro requested a review from abonie May 20, 2026 16:10
@T-Gro T-Gro removed the auto-merge label May 20, 2026
@github-actions github-actions Bot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label May 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Commit pushed: ae983dd

Generated by LabelOps — PR Maintenance

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor


Note

The pull request was not created — a fallback review issue was created instead due to protected file changes: #19781

🤖 LabelOps — Conflict Resolution.

Merged main into this branch. The merge resolved cleanly (auto-merge on docs/release-notes/.FSharp.Compiler.Service/11.0.100.md and tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj). CI should restart automatically.

Generated by LabelOps — PR Maintenance · ● 22.8M ·

@T-Gro T-Gro removed AI-Auto-Resolve-CI Opt-in: LabelOps triages CI failures on this PR every 3h AI-Auto-Resolve-Conflicts Opt-in: LabelOps merges main into this PR and resolves conflicts every 3h labels May 21, 2026
T-Gro and others added 10 commits May 21, 2026 11:16
Tests demonstrate that --nowarn:N does not suppress warnings emitted
during command-line option parsing (e.g. FS0075 for internal/test-only
options like --extraoptimizationloops, --typedtree).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ng (#19576)

Wrap the logger used to replay delayed command-line diagnostics with
GetDiagnosticsLoggerFilteringByScopedNowarn so that --nowarn / --warnaserror /
warn-level switches set on the command line are honored for diagnostics
captured during option parsing (e.g. FS0075 from internal/test-only flags
such as --extraoptimizationloops or --typedtree).

The fix is applied both on the success path (fsc.fs main1, line ~586) and
on the error/exit paths via the IDiagnosticsLoggerProvider extension method,
making it universal across fsc.exe and FSharpChecker.Compile.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The third test added in TDD red phase was speculative (warning numbers
didn't match) and outside the scope of sprint 2's DoD. Sprint 2 only
required the first two tests (FS0075 for --extraoptimizationloops and
--typedtree) to pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Introduce a local 'warningCmdLine' helper that consults
tcConfigB.diagnosticsOptions via PhasedDiagnostic.AdjustSeverity before
forwarding to warning/errorR/informationalWarning. This gives option
parsing a second, local line of defense so future 'warning' callsites in
CompilerOptions.fs cannot silently bypass --nowarn/--warnaserror even if
the commit-time delayed-diagnostics wrapper is missing.

- Thread TcConfigBuilder through ParseCompilerOptions (all 6 callers).
- Thread TcConfigBuilder through CheckAndReportSourceFileDuplicates.
- Route the three cowboy 'warning' callsites in CompilerOptions.fs
  (reportDeprecatedOption, --test unknown-arg, duplicate source file)
  through warningCmdLine.
- Add a regression test for FS1063 (--test unknown sub-flag).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The emit-time warningCmdLine helper was order-dependent (only worked when
--nowarn preceded the triggering option) and introduced a regression with
--warnaserror+ (premature abort via errorR incrementing ErrorCount before
--nowarn could take effect).

Replace with commit-time filtering via GetDiagnosticsLoggerFilteringByScopedNowarn
at the two sites in fsc.fs where CapturingDiagnosticsLogger replays captured
diagnostics. This correctly applies all --nowarn/--warnaserror settings
accumulated during the full option parsing pass.

Revert ParseCompilerOptions and CheckAndReportSourceFileDuplicates signatures
to their original forms (no TcConfigBuilder parameter needed).

Add missing tests:
- Baseline tests verifying warnings ARE emitted without --nowarn
- --warnaserror+ with --nowarn interaction test

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…serror semantics

Add tests identified by multi-model adversarial review:
- Reverse-order test (--option before --nowarn) proves commit-time
  filtering works regardless of argument ordering
- --warnaserror+ baseline proving warning is promoted to error
- --warnaserror+ with --nowarn proving nowarn takes precedence (global)
- --warnaserror:75 with --nowarn:75 documenting that specific
  warnaserror wins over --nowarn (AdjustSeverity uses localNowarn
  for specific, warnOff for global)

13 tests total, 0 duplication of test source code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Triggers both FS0075 and FS1063 simultaneously, suppresses only FS0075
via --nowarn:75, and asserts FS1063 still fires. Catches regressions
where filtering accidentally drops all command-line warnings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…x CI

The file was tracked by git as CompilerOptions/Fsc/warn/ (uppercase) while
the fsproj and all sibling files use lowercase fsc/. On case-sensitive Linux
this caused FS0225 'source file not found'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove type annotation restating what inference provides
- Replace code-restating comments with WHY-comments
- Add test: --nowarn before --warnaserror+ still suppresses

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro T-Gro force-pushed the fix/nowarn-75 branch 2 times, most recently from 9a40dce to cdc71fc Compare May 21, 2026 10:52
Remove mechanical test duplicates (15→7): drop Theory×3 testing same
warn number with different triggers, drop duplicate withNoWarn vs raw
--nowarn:N tests, drop redundant order-independence test.
Move release notes to 11.0.100.md (VNEXT).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling May 21, 2026
@abonie abonie merged commit a690556 into main May 21, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

NoWarn doesn't affect FS0075

2 participants