Skip to content

RAN001 Fable inlines a snapshot of a module mutable

warning RAN001: Fable Release compiles setups as a second read of Loops.childSetups at its single use (line 5), so writes between the two lines change it.

Cause. Fable 5.18 Release, Fickl 0.3.0 (Fable 5.22) Release, and the pinned Fickl 0.5.3 (Fable 5.23) Release replace a single-use immutable let whose right-hand side is a bare read of a module-level let mutable declared in another file with a second read at the use. The snapshot then sees the writes made between the binding and the use. A use inside a closure and a tuple pattern are inlined the same way. The rule runs in a project that Fable compiles, whichever compiler version builds it: see Where the rules run.

Fix. Declare the snapshot let mutable. The rule's fix inserts mutable; a tuple pattern has no fix.

The mutable lives in another file:

Shared: Loops.fs

module Loops

let mutable childSetups = 0

let setup () = childSetups <- childSetups + 1

Triggers

module Example

let snapshot () =
    let setups = Loops.childSetups
    Loops.setup ()
    Loops.childSetups - setups

Fixed

module Example

let snapshot () =
    let mutable setups = Loops.childSetups
    Loops.setup ()
    Loops.childSetups - setups

Suppression. // fsharpanalyzer: ignore-line-next RAN001, with the reason on the line before.

Edit this page