Multiple Constructors require different syntax
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
_Originally from here: https://github.com/fsharp/fsharp/issues/827_
When adding constructors to to an F# class the required syntax changes, e.g. is different for the last constructor (for single parameter `.ctor`s).
#### Repro steps
While the following code is valid…
```F#
type A (a : int option, b : string option) =
new a = A (a, None)
member __.X = ""
```
… adding another `.ctor` with one parameter in a similar fashion does not validate anymore:
```F#
type A (a : int option, b : string option) =
new a = A (a, None)
new b = A (None, b)
member __.X = ""
```
The error on the `=` on the third line is: `error FS0010: Unexpected symbol '=' in expression`
#### Known workarounds
Parameters of the not-last `.ctor` must be wrapped in braces. For a yet bigger example this gives:
```F#
type A (a : int option, b : string option, c : float option) =
new (a) = A (a, None, None)
new (b) = A (None, b, None)
new c = A (None, None, c)
member __.X = ""
```
(Also omitting the first brace (in `new (a)`) does break the thing.)
#### Related information
Observed on Win 10 in VS and Ionide with latest releases installed.
Severity is most probably low.
Contributor guide
Assessment
This issue has not been assessed yet.