* defaults to Orc * bootstrap using refc * use gc * init orc defines * unregister orc * fix gc * fix commands * add prepareMutation for orc * enable deepcopy for orc * prepareMutation * more fixes * some cases * bug #20081 * partial fixes * partial fixes * fixes command line * more fixes * build Nim with refc * use gc * more fixes * rstore * orc doesn't support threadpool * more shallowCopy * more fixes * fixes unsafeNew * workarounds * small * more fixes * fixes some megatest * tcodegenbugs1 refc * fxies megatest * build nimble with refc * workaround tensordsl tests * replace shallowCopy with move * fixes action * workaround * add todo * fixes important packages * unpublic unregisterArcOrc * fixes cpp * enable windows Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
54 lines
1.1 KiB
Nim
54 lines
1.1 KiB
Nim
discard """
|
|
output: '''true'''
|
|
"""
|
|
|
|
# We need to open the gensym'ed symbol again so that the instantiation
|
|
# creates a fresh copy; but this is wrong the very first reason for gensym
|
|
# is that scope rules cannot be used! So simply removing 'sfGenSym' does
|
|
# not work. Copying the symbol does not work either because we're already
|
|
# the owner of the symbol! What we need to do is to copy the symbol
|
|
# in the generic instantiation process...
|
|
|
|
type
|
|
TA = object
|
|
x: int
|
|
TB = object
|
|
x: string
|
|
|
|
template genImpl() =
|
|
var gensymed: T
|
|
when T is TB:
|
|
gensymed.x = "abc"
|
|
else:
|
|
gensymed.x = 123
|
|
result = move gensymed
|
|
|
|
proc gen[T](x: T): T =
|
|
genImpl()
|
|
|
|
var
|
|
a: TA
|
|
b: TB
|
|
let x = gen(a)
|
|
let y = gen(b)
|
|
|
|
doAssert x.x == 123
|
|
doAssert y.x == "abc"
|
|
|
|
# test symbol equality
|
|
|
|
import macros
|
|
|
|
static:
|
|
let sym1 = genSym()
|
|
let sym2 = genSym()
|
|
let sym3 = sym1
|
|
let nimsym = sym1.symbol
|
|
doAssert sym1 == sym1
|
|
doAssert sym2 != sym3
|
|
doAssert sym2.symbol != sym3.symbol
|
|
doAssert sym3 == sym1
|
|
doAssert sym1.symbol == sym1.symbol
|
|
doAssert nimsym == nimsym
|
|
|
|
echo "true"
|