proc Match(Subject: VString; Pat: Pattern): bool =
  var Start: Natural
  var Stop: Natural
  
  if Debug_Mode:
    XMatchD(true, Subject, Pat.P, Pat.Stk, Start, Stop)
  else:
    XMatchD(false, Subject, Pat.P, Pat.Stk, Start, Stop)
  
  return Start != 0where XMatchD is a large complex parsing function of the form:
proc XMatchD(debug: static[bool];
             Subject: VString;
             Pat_P: PE_Ptr;
             Pat_S: Natural;
             Start: var Natural;
             Stop: var Natural) =containing when debug: statements. While this approach worked fine for small functions with XMatchD I get the compiler error:
???(-1717, 0) Error: illformed AST: ()
I am using the latest dev Nim and no additional compilation options. Is debug: static[bool] the best way to instantiate two versions of XMatchD or is there a better way? Should I get this error? If so why only on XMatchD but not with other functions?
P.S. Ignore the horrid Ada naming convention in this code, I will nimify it when it works.
type State = enum Match_Fail, Match_Succeed, Fail, Succeed, Matchwhich worked fine without the debug: static[bool] parameter but now it only compiles if I move this type definition outside the XMatchD function.
Great, but please use the bug tracker (github issues).
Btw, I'd just use a template to instantiate 2 separate procs.
I will try to produce a small example which reproduces the problem and post it as a github issue.
I first tried creating a generic function instantiated on a static[bool] but could not find how to do the equivalent of the C++ func<true>(arguments) and func<false>(arguments) but found that the static argument in neater anyway. I guess I could use a template but haven't played much with those yet.
proc match(debug: static[bool]; str: string) =
  type state = enum found, fail
  echo strI have submitted it as an github issue.