Skip to content

[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
mainfrom
repo-assist/fix-issue-3273-named-indexed-property-space-ac071db735be26df
Closed

github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/fix-issue-3273-named-indexed-property-space-ac071db735be26df

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Closes #3273

🤖 This PR was created by Repo Assist, an automated AI assistant. Please review carefully.

Problem

NamedIndexedPropertySet expressions with a multi-part identifier as the index were losing the required space between the property name and the index expression:

Input:

a.B c.DE <- 0

Before this fix (wrong — invalid F#):

a.Bc.DE <- 0

After this fix:

a.B c.DE <- 0

Root Cause

In CodePrinter.fs, the sep logic for Expr.NamedIndexedPropertySet only added sepSpace for Expr.Constant and Expr.Ident index expressions:

let sep =
    match node.Index with
    | Expr.Constant _
    | Expr.Ident _ -> sepSpace
    | _ -> sepNone

A multi-segment identifier like c.DE maps to SynExpr.LongIdent in the F# AST, which becomes Expr.OptVar in the Oak representation. Since Expr.OptVar was not in the sepSpace case, the separator was omitted, merging the property name and the index into one.

Fix

Add Expr.OptVar _ to the sepSpace case:

let sep =
    match node.Index with
    | Expr.Constant _
    | Expr.Ident _
    | Expr.OptVar _ -> sepSpace
    | _ -> sepNone

Test Status

  • ✅ Build: dotnet build fantomas.sln — succeeded
  • ✅ Tests: dotnet test src/Fantomas.Core.Tests/ — 2737 passed, 0 failed, 7 skipped
  • ✅ New regression test added: long ident index in NamedIndexedPropertySet preserves space, 3273

Generated by Repo Assist · ◷

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

…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>
@nojaf nojaf closed this Mar 11, 2026
@nojaf
nojaf deleted the repo-assist/fix-issue-3273-named-indexed-property-space-ac071db735be26df branch August 19, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NamedIndexedPropertySet with two SynLongIdent remove space

1 participant