Nim icon indicating copy to clipboard operation
Nim copied to clipboard

repr complex generics with distinct reaches call depth limit with ARC/ORC

Open ringabout opened this issue 1 year ago • 1 comments

type
  BaseUint* = SomeUnsignedInt or byte
  Ct*[T] = distinct T
    ## Constant-Time wrapper
    ## Only constant-time operations in particular the ternary operator equivalent
    ##   condition: if true: a else: b
    ## are allowed

  CTBool*[T] = distinct range[T(0)..T(1)]
    ## Constant-Time boolean wrapper

var x: array[8, CTBool[Ct[uint32]]]
x[0] = (CTBool[Ct[uint32]])(1)
echo x.repr, " ", typeof(x[0])
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.

ringabout avatar Aug 04 '22 11:08 ringabout

Reduced a bit

type
  Ct*[T] = distinct T
  CTBool*[T] = range[T(0)..T(1)]

var x: CTBool[Ct[uint32]]
echo x.repr

ringabout avatar Aug 04 '22 11:08 ringabout