fsharp / fsharp/fslang-suggestions
Tracking suggestion: Misaligned methods
- Dominant language
- No language data
- Stars
- 373
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
There is a proposal to adjust the syntax rules to give errors or warnings for misaligned methods
See https://github.com/Microsoft/visualfsharp/issues/1504, pasted below
## Case 1
#### Repro steps
Provide the steps required to reproduce the problem
Take this code:

#### Expected behavior
It should complain at the declaration of `test 2`.
#### Actual behavior
It compiles without errors or warnings.
---
## Case 2
Now, this case isn't actually that bad. What had me and a colleague stumped for some time was the behaviour, when you add a loop to the method:

If I remove two spaces each from the method declaration, it compiles.
In our more complex example, there was an error `this value is not a function and can not be applied` in the middle of the method, but if you copied the whole code block into another method, it compiled. Removing the block also made the method compile.
#### Code
```fsharp
module Tests
open System.IO
open System.Xml.Linq
open System
open System.Xml
open System.Security.Cryptography
open Xunit
type FSharpTests() =
[]
member __.``test 1``() =
()
[]
member __.``test 2``() =
let folder = Path.Combine(__SOURCE_DIRECTORY__, @"..\..\Data")
let paths = [| Path.Combine(folder, "1")
Path.Combine(folder, "2") |]
ignore paths.Length
// for x in paths do ()
// ()
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the two F# reproductions in the issue and read the linked visualfsharp issue for additional context. Investigate how syntax rules handle the differently indented method declarations and the loop variant. Done means the first case produces the requested error or warning and the behavior of the second case is addressed consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fsharp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100