Open ee7 opened 3 years ago
Minimizing the code slightly:
import std/sequtils
var seqReverse: proc(str: seq[char]): seq[char]
seqReverse = proc(str: seq[char]): seq[char] =
if str.len == 1:
str[0..0]
else:
var slice = str
slice.delete(0, 0)
concat(seqReverse(slice), str[0..0])
proc reverse*(str: string): string =
for c in seqReverse(toSeq(str)):
result.add c
The problem is that the empty string test case causes an infinite recursion. So when the tests call
check reverse("") == ""
we get
/usr/lib/nim/system/assign.nim(179) genericSeqAssign
/usr/lib/nim/system/assign.nim(143) genericAssign
/usr/lib/nim/system/assign.nim(89) genericAssignAux
/usr/lib/nim/system/mmdisp.nim(104) nimNewSeqOfCap
/usr/lib/nim/system/gc.nim(482) newObjNoInit
/usr/lib/nim/system/alloc.nim(753) rawAlloc
/usr/lib/nim/system/osalloc.nim roundup
Error: call depth limit reached in a debug build (2000 function calls). You can change it with -d:nimCallDepthLimit=<int> but really try to avoid deep recursions instead.
A minimal reproducible example:
proc reverse*(s: string): string =
reverse(s)
echo reverse("foo")
I'm having a hard time debugging because no stack trace was printing as is the expected behaviour for -d:release
. I'm guessing that the issue is when there is a runtime exception, results.json
file isn't written properly, and therefore when parsing the results.json
file to reinsert the stdout there is a parsing error and the program just exits.
@iHiD is there a way to get the /mnt/exercism-iteration/results.json
from that run? I also just tried the same kind of thing and got the same error.
I will try and test locally
The results.json
is written without any contents. That fits the error message:
Error: unhandled exception: /mnt/exercism-iteration/results.json(1, 0) Error: { expected [JsonParsingError]
Opened a draft https://github.com/exercism/nim-test-runner/pull/87, but I'm away for a bit.
Reported by @axtens in Slack:
The error:
The website produces the message: