Yesterday I finished my Nim conversion of the C++ QuickHullOfDisks algorithm from the 2019 paper and first message of first test run was:
/home/salewski/quickhulldisk/geometricfunction2d.nim(87) make_exterior_tangent_lines_of_two_circles
/home/salewski/Nim/lib/system/assign.nim(143) genericAssign
/home/salewski/Nim/lib/system/assign.nim(129) genericAssignAux
/home/salewski/Nim/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: invalid object assignment [ObjectAssignmentDefect]
Looks like some debugging fun for whole weekend?
But google saved me that work, pointing me to
https://github.com/nim-lang/Nim/issues/11592
So let us take this small example program, compile with default gc and with ARC and run it:
# $ cat t.nim
type
T1 = object of RootObj
i: int
type
T2 = object of T1
j: int
proc test(v: T1) =
echo v.i
var x: T1
x = v
echo x.i
proc main =
var x = T2(i: 0, j: 1)
test(x)
main()
$ nim c t.nim
Hint: used config file '/home/salewski/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/salewski/Nim/config/config.nims' [Conf]
....
CC: t.nim
Hint: [Link]
Hint: 22873 lines; 0.217s; 25.703MiB peakmem; Debug build; proj: /tmp/hhh/t.nim; out: /tmp/hhh/t [SuccessX]
salewski@nuc /tmp/hhh $ ./t
0
/tmp/hhh/t.nim(19) t
/tmp/hhh/t.nim(17) main
/tmp/hhh/t.nim(12) test
/home/salewski/Nim/lib/system/assign.nim(143) genericAssign
/home/salewski/Nim/lib/system/assign.nim(129) genericAssignAux
/home/salewski/Nim/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: invalid object assignment [ObjectAssignmentDefect]
salewski@nuc /tmp/hhh $ nim c --gc:arc t.nim
Hint: used config file '/home/salewski/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/salewski/Nim/config/config.nims' [Conf]
....
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: t.nim
Hint: [Link]
Hint: 21172 lines; 0.372s; 25.594MiB peakmem; Debug build; proj: /tmp/hhh/t.nim; out: /tmp/hhh/t [SuccessX]
salewski@nuc /tmp/hhh $ ./t
0
0
salewski@nuc /tmp/hhh $
$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-03-30
Copyright (c) 2006-2021 by Andreas Rumpf
git hash: 9e88425d7c5e3edfcbddedbe062c5f028789a002
active boot switches: -d:release