I am reviewing some code that I did some time ago and has stopped working properlly. The code wraps a C library (vapoursynth).
What is happening is that the code works when run with `--d:danger` but it fails without it. The code is pretty simple. In one hand: import ../src/vapoursynth discard Source("2sec.mkv").Turn180 Run The function `Turn180` is the one that is producing the failure: proc Turn180*(vsmap:ptr VSMap):ptr VSMap = echo "A: ",vsmap.len("clip") let plug = getPluginById("com.vapoursynth.std") echo "B: ",vsmap.len("clip") #echo repr cast[pointer](vsmap) #let args = createMap() #args.append("clip", clip) assert( plug != nil, "plugin \"com.vapoursynth.std\" not installed properly in your computer") echo "C: ",vsmap.len("clip") assert( vsmap.len != 0, "the vsmap should contain at least one item") echo "D: ",vsmap.len("clip") assert( vsmap.len("clip") != 1, "the vsmap should contain one node") echo "E: ",vsmap.len("clip") var clip = getFirstNode(vsmap) # Convert the function parameters into a VSMap (taking into account that some of them might be optional) let args = createMap() args.append("clip", clip) result = API.invoke(plug, "Turn180".cstring, args) API.freeMap(args) Run When I run it without `--d:danger`: $ nim c --threads:on --tlsSimulation:off ex01 $ ./ex01 A: 1 B: 1 C: 1 D: 1 /home/jose/src/VapourSynth.nim/test/ex01.nim(10) ex01 /home/jose/src/VapourSynth.nim/src/plugins/std.nim(1104) Turn180 /home/jose/.choosenim/toolchains/nim-1.4.2/lib/system/assertions.nim(30) failedAssertImpl /home/jose/.choosenim/toolchains/nim-1.4.2/lib/system/assertions.nim(23) raiseAssert /home/jose/.choosenim/toolchains/nim-1.4.2/lib/system/fatal.nim(49) sysFatal Error: unhandled exception: /home/jose/src/VapourSynth.nim/src/plugins/std.nim(1104, 9) `vsmap.len("clip") != 1` the vsmap should contain one node [AssertionDefect] Run so I don't know how can I get `D: 1` and then failing in the next assertion. Any idea about what might be going on?