fsharp / fsharp/fslang-suggestions

Undentation for string interpolation arguments

Open
#1,111 1 comment 9 reactions 0 assignees View on GitHub
approved-in-principle area: syntax
Dominant language
No language data
Stars
373
Forks
21
PR merge metrics
No merged PRs in 30d

Description

# Undentation for string interpolation arguments

In https://github.com/fsharp/fslang-design/blob/main/FSharp-6.0/FS-1108-undentation-frenzy.md, indentation warnings induced by 9 pairs of expression brackets were removed. However,
```fs
printfn $"{
1 // warning FS0058: Possible incorrect indentation
}"
```
This was missed!
I propose we add the curly brackets as delimiters of interpolated string arguments to the 9 pairs of brackets that don't impose an additional indentation limit to the following line.

The existing way of approaching this problem in F# is
```fs
printfn $"{(
1 // Parentheses weirdly eliminate the warning
)}"
```
or having a `let` declaration above.

## Pros and Cons

The advantages of making this adjustment to F# are
1. Consistency
2. Conciseness
3. Convenience

The disadvantage of making this adjustment to F# is, as with the disadvantages listed under the Drawbacks section of the proposal,
> undentations must be applied with care as they can cause code to be written that is less readable. However, since the undentation is already allowed for numerous cases listed under Motivation it seems reasonable to get uniformity here.

## Extra information

Estimated cost (XS, S, M, L, XL, XXL): S

Related suggestions: (put links to related suggestions here)

## Affidavit (please submit!)

Please tick this by placing a cross in the box:
* [x] This is not a question (e.g. like one you might ask on [stackoverflow](http://stackoverflow.com)) and I have searched stackoverflow for discussions of this issue
* [x] I have [searched both open and closed suggestions on this site](http://github.com/fsharp/fslang-suggestions/issues) and believe this is not a duplicate
* [x] This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.

Please tick all that apply:
* [x] This is not a breaking change to the F# language design
* [x] I or my company would be willing to help implement and/or test this

## For Readers

If you would like to see this issue implemented, please click the :+1: emoji on this issue. These counts are used to generally order the suggestions by engagement.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the linked FS-1108 undentation-frenzy proposal and reproduce the interpolated-string examples in this issue. Investigate where F# indentation warnings are defined for expression brackets, then verify that curly brackets in interpolated string arguments follow the same behavior and that the warning is absent.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.