My Nim program containing self-referencing data types works fine with the default GC. When I try to compile with --mm:orc or --mm:arc I see the below error.
Minimal reproducer that I could build
# main.nim
import std/options
type
C = ref object
outer: Option[C]
proc newC(outer: Option[C] = none(C)): C =
result = C(outer:outer)
let a = newC()
let b: C = newC(some(a))
echo b.outer.get.outer.isSome
Command
nim c --mm:orc -r main.nim
Exception:
/home/user/.cache/nim/main_d/@mmain.nim.c: In function 'eqcopy___main_25':
/home/user/.cache/nim/main_d/@mmain.nim.c:448:9: error: 'tyObject_Option__CmYV9aVDOcpb9ayE5hgOg4mg' {aka 'struct tyObject_Option__CmYV9aVDOcpb9ayE5hgOg4mg'} has no member named 'has'
448 | (*dest).has = src.has;
| ^
/home/user/.cache/nim/main_d/@mmain.nim.c:448:19: error: 'tyObject_Option__CmYV9aVDOcpb9ayE5hgOg4mg' {aka 'struct tyObject_Option__CmYV9aVDOcpb9ayE5hgOg4mg'} has no member named 'has'
448 | (*dest).has = src.has;
| ^
/home/user/.cache/nim/main_d/@mmain.nim.c: In function 'newC__main_11':
/home/user/.cache/nim/main_d/@mmain.nim.c:467:14: error: 'tyObject_Option__CmYV9aVDOcpb9ayE5hgOg4mg' {aka 'struct tyObject_Option__CmYV9aVDOcpb9ayE5hgOg4mg'} has no member named 'has'
467 | (*T1_).outer.has = colontmpD_.has;
| ^
compilation terminated due to -fmax-errors=3.
Error: execution of an external compiler program 'gcc -c -w -fmax-errors=3 -I/home/user/.choosenim/toolchains/nim-1.6.2/lib -I/home/user/trash/tmp-2022-01-16-aVq -o /home/user/.cache/nim/main_d/@mmain.nim.c.o /home/user/.cache/nim/main_d/@mmain.nim.c' failed with exit code: 1
Nim version
$ nim --version
Nim Compiler Version 1.6.2 [Linux: amd64]
Compiled at 2021-12-17
Copyright (c) 2006-2021 by Andreas Rumpf
git hash: 9084d9bc02bcd983b81a4c76a05f27b9ce2707dd
active boot switches: -d:release