Consider this program named bug1.nim:
    
    
    import os, strutils
    let n = [1, 2]
    echo n[paramStr(1).parseInt]
    
    
    Run

And some runs of it (hiding some options that only make the output less noisy):
    
    
    $ nim r bug1 4
    bug1.nim(3)              bug1
    fatal.nim(49)            sysFatal
    Error: unhandled exception: index 4 not in 0 .. 1 [IndexDefect]
    
    $ nim -d:release r bug1 4
    fatal.nim(49)            sysFatal
    Error: unhandled exception: index 4 not in 0 .. 1 [IndexDefect]
    
    
    Run

The normal build pinpoints the line in the program that leads to the bug. The 
release build doesn't do this.

So how can we get that information into the release build?

Answer: add `--stackTrace:on --lineTrace:on` to the build options:
    
    
    $ nim -d:release --stackTrace:on --lineTrace:on r bug1 4
    bug1.nim(3)              bug1
    fatal.nim(49)            sysFatal
    
    
    Run

Hopefully your bug still shows up in the presence of these features.

Reply via email to