On devel a new experimental mode has arrived called "strictFuncs". See also 
[https://github.com/nim-lang/RFCs/issues/234](https://github.com/nim-lang/RFCs/issues/234)

For example:
    
    
    {.experimental: "strictFuncs".}
    
    type
        Node = ref object
          le, ri: Node
          data: string
    
    func len(n: Node): int =
        # valid: len does not have side effects
        var it = n
        while it != nil:
          inc result
          it = it.ri
    
    func mut(n: Node) =
        let m = n # is the statement that connected the mutation to the 
parameter
        m.data = "yeah" # the mutation is here
        # Error: 'mut' can have side effects
        # an object reachable from 'n' is potentially mutated
    
    
    
    
    Run

Reply via email to