Closed Cloudperry closed 2 years ago
This is the compiler output:
roni@roni-desktop ~/Testing> nim c nimRegexBug.nim
Hint: used config file '/etc/nim/nim.cfg' [Conf]
Hint: used config file '/etc/nim/config.nims' [Conf]
..........................................Traceback from system (most recent call last)
Error: unhandled exception: index -1 not in 0 .. 0 [IndexDefect]
I don't see any useful information there, but at least it tells that the compiler crashes before c codegen happens. The crash happens on all backends except javascript and is unaffected by the choice of gc.
The workaround for this is to first store the command line argument to a variable. This compiles:
import os, regex
let firstArg = commandLineParams()[0]
discard re(firstArg)
Clearly not a nim-regex bug. Idk why I thought it wasn't a compiler bug.
Compiling the following program with Nim 1.4.8 crashes the compiler:
Running the same program through nimsuggest also crashes the nimsuggest instance. The program compiles when regex is replaced with re or nre. I don't know yet if this is a compiler bug or a nim-regex bug, but it sure seems like its in nim-regex.