Skip to content

Stop FSI from mutating script arguments after -- separator#19926

Open
T-Gro wants to merge 4 commits into
mainfrom
fix/issue-10819
Open

Stop FSI from mutating script arguments after -- separator#19926
T-Gro wants to merge 4 commits into
mainfrom
fix/issue-10819

Conversation

@T-Gro

@T-Gro T-Gro commented Jun 9, 2026

Copy link
Copy Markdown
Member

Fixes #10819

fsi.CommandLineArgs was colon-joining abbreviated flags (-d, -r, -I)
with their next token when they appeared after --. Now PostProcessCompilerArgs
splits at the first -- and only post-processes the compiler-args prefix.

Copilot and others added 3 commits June 9, 2026 22:10
RED phase: pin down the correct behaviour of fsi.CommandLineArgs when user

arguments follow the -- separator. The abbreviated flags -d, -r, -I are

currently colon-joined with their next token (e.g. '-- -d 5' becomes '-d:5'

instead of staying as two tokens), which these tests assert against.

Theory rows fail on current main; the baseline [<Fact>] passes and locks in

the current treatment of non-abbreviated post-'--' args so the GREEN fix

cannot regress them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
 #10819)

Split argv at the first `--` and only post-process the compiler-args prefix; the suffix (including the `--` separator itself) reaches downstream handlers byte-for-byte. Keeping `--` in the suffix preserves two paths:

* with a script preceding `--`, the script's OptionGeneral IsScript handler captures the suffix as script args (matching pre-fix behaviour for fsi.CommandLineArgs);

* with no script (e.g. `dotnet fsi -- -d 5`), the `--` token reaches ParseCompilerOptions and fires its OptionRest recordExplicitArg handler so `-d` and `5` are recorded as explicit args instead of being parsed as compiler options.

Updates the regression test theory to expect `--` in the captured tail and adds a new no-script Fact that locks the OptionRest path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fantomas-applied formatting in src/Compiler/Interactive/fsi.fs (whitespace
and pattern-match line collapse only; no behavioural change) and a single
new bullet under ### Fixed in docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
referencing Issue #10819.

Validation: focused regression filters (FsiCommandLineArgsTests,
CommandLineArgs, FsiCliTests) green under -c Release on both net10.0 and
net48. SurfaceAreaTest passes on net10.0 with no baseline update (net48
has zero tests for that filter - platform-conditional). Full
FSharp.Compiler.ComponentTests and FSharp.Compiler.Service.Tests suites
were run under -c Release as the documented alternative to
'./build.sh -c Release --testcoreclr'; the only failures observed were
two well-known flaky ScriptOptionsTests nuget-resolution tests on net48
(unrelated to argument handling; confirmed flaky in isolation; net10.0
runs all 4364 tests green).

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

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev


✅ 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

@github-actions github-actions Bot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label Jun 9, 2026
@T-Gro T-Gro requested a review from abonie June 12, 2026 10:08
// otherwise fsi.CommandLineArgs leaks the rewrite to scripts (see #10819).
// Split argv at the first `--`, post-process only the compiler-args prefix,
// and pass the suffix (including the `--` separator itself) through unmodified.
// Keeping `--` in the suffix preserves both downstream handlers:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A lot of this comment's contents is coupled to code that's not even in this file. In case of future changes downstream, it's very unlikely this comment gets updated as well. At least trim it down. The useful part of this comment is its first ~3 lines

@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling Jun 19, 2026
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

Status: In Progress

Development

Successfully merging this pull request may close these issues.

fsi.CommandLineArgs different behavior on -d/-r/-I args, ignores --.

2 participants