[From VSTS] Getting ref to static mutable field is an error in F# 4.5
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
Referencing a class static mutable field via & stopped compiling in F# 4.5. Example:
```fsharp
type MyClass () =
[]
static val mutable private nextInstanceIndex : int
static do
MyClass.nextInstanceIndex <- 1
let instanceIndex = System.Threading.Interlocked.Increment(&MyClass.nextInstanceIndex) - 1
```
Compilation results in error FS3236: Cannot take the address of the value returned from the expression. Assign the returned value to a let-bound value before taking the address.
_This issue has been moved from https://developercommunity.visualstudio.com/content/problem/301281/getting-ref-to-static-mutable-field-is-an-error-in.html
VSTS ticketId: 655347_
_These are the original issue comments:_
James Horvath on 7/27/2018, 08:32 AM (3 days ago):
Here's that code formatted:
type MyClass () =
[<DefaultValue>]
static val mutable private nextInstanceIndex : int
static do
MyClass.nextInstanceIndex <- 1
let instanceIndex = System.Threading.Interlocked.Increment(&MyClass.nextInstanceIndex) - 1
_These are the original issue solutions:_
(no solutions)
Contributor guide
Assessment
This issue has not been assessed yet.