Repository navigation
[Repo Assist] Fix missing space in NamedIndexedPropertySet when index is a long identifier (#3273) - #3275
Closed
github-actions[bot] wants to merge 1 commit into
Conversation
…ntifier (#3273) When the index expression of a NamedIndexedPropertySet is an OptVar (i.e. a multi-segment identifier like `c.DE`), Fantomas was omitting the required space between the property name and the index, producing invalid code such as `a.Bc.DE <- 0` instead of `a.B c.DE <- 0`. The sep logic only covered Expr.Constant and Expr.Ident; this commit adds Expr.OptVar to the sepSpace case. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3 of 4 tasks
nojaf
deleted the
repo-assist/fix-issue-3273-named-indexed-property-space-ac071db735be26df
branch
August 19, 2026 06:46
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.
Closes #3273
🤖 This PR was created by Repo Assist, an automated AI assistant. Please review carefully.
Problem
NamedIndexedPropertySetexpressions with a multi-part identifier as the index were losing the required space between the property name and the index expression:Input:
Before this fix (wrong — invalid F#):
After this fix:
Root Cause
In
CodePrinter.fs, theseplogic forExpr.NamedIndexedPropertySetonly addedsepSpaceforExpr.ConstantandExpr.Identindex expressions:A multi-segment identifier like
c.DEmaps toSynExpr.LongIdentin the F# AST, which becomesExpr.OptVarin the Oak representation. SinceExpr.OptVarwas not in thesepSpacecase, the separator was omitted, merging the property name and the index into one.Fix
Add
Expr.OptVar _to thesepSpacecase:Test Status
dotnet build fantomas.sln— succeededdotnet test src/Fantomas.Core.Tests/— 2737 passed, 0 failed, 7 skippedlong ident index in NamedIndexedPropertySet preserves space, 3273