Hi

I have below code. It works on the Nim playground 
(<https://play.nim-lang.org/#ix=3BCY>) but is failing on my local. If I remove 
proc x, it works. Wonder whether it's something with my installation or the 
specific Nim version I have.
    
    
    type
      A = ref object
        p: int
    
    let a = A(p: 0)
    a.p = 1
    var b = a
    b.p = 2
    
    proc x(a: A) =
      a.p = 3
    
    echo a.p
    echo b.p
    
    
    Run
    
    
    $ nim -v
    Nim Compiler Version 1.4.6 [MacOSX: amd64]
    Compiled at 2021-05-22
    Copyright (c) 2006-2020 by Andreas Rumpf
    
    active boot switches: -d:release
    $ nim c -r tests/scratch9.nim
    /Users/gcao/proj/gene/tests/scratch9.nim(10, 6) Hint: 'x' is declared but 
not used [XDeclaredButNotUsed]
    CC: scratch9.nim
    Hint: /Users/gcao/proj/gene/bin/scratch9  [Exec]
    Traceback (most recent call last)
    /Users/gcao/proj/gene/tests/scratch9.nim(13) scratch9
    SIGSEGV: Illegal storage access. (Attempt to read from nil?)
    Error: execution of an external program failed: 
'/Users/gcao/proj/gene/bin/scratch9 '
    
    
    Run

Reply via email to