parent
41cf609fc7
commit
2bf337abae
2 changed files with 23 additions and 0 deletions
|
|
@ -133,6 +133,9 @@ proc evalTypeTrait(c: PContext; traitCall: PNode, operand: PType, context: PSym)
|
||||||
template typeWithSonsResult(kind, sons): PNode =
|
template typeWithSonsResult(kind, sons): PNode =
|
||||||
newTypeWithSons(context, kind, sons).toNode(traitCall.info)
|
newTypeWithSons(context, kind, sons).toNode(traitCall.info)
|
||||||
|
|
||||||
|
if operand.kind == tyGenericParam or (traitCall.len > 2 and operand2.kind == tyGenericParam):
|
||||||
|
return traitCall ## tpo early to evaluate
|
||||||
|
|
||||||
let s = trait.sym.name.s
|
let s = trait.sym.name.s
|
||||||
case s
|
case s
|
||||||
of "or", "|":
|
of "or", "|":
|
||||||
|
|
|
||||||
|
|
@ -101,3 +101,23 @@ block genericParams:
|
||||||
static: doAssert (int, float).lenTuple == 2
|
static: doAssert (int, float).lenTuple == 2
|
||||||
static: doAssert (1, ).lenTuple == 1
|
static: doAssert (1, ).lenTuple == 1
|
||||||
static: doAssert ().lenTuple == 0
|
static: doAssert ().lenTuple == 0
|
||||||
|
|
||||||
|
|
||||||
|
##############################################
|
||||||
|
# bug 13095
|
||||||
|
|
||||||
|
type
|
||||||
|
CpuStorage{.shallow.}[T] = ref object
|
||||||
|
when supportsCopyMem(T):
|
||||||
|
raw_buffer*: ptr UncheckedArray[T] # 8 bytes
|
||||||
|
memalloc*: pointer # 8 bytes
|
||||||
|
isMemOwner*: bool # 1 byte
|
||||||
|
else: # Tensors of strings, other ref types or non-trivial destructors
|
||||||
|
raw_buffer*: seq[T] # 8 bytes (16 for seq v2 backed by destructors?)
|
||||||
|
|
||||||
|
var x = CpuStorage[string]()
|
||||||
|
|
||||||
|
static:
|
||||||
|
doAssert(not string.supportsCopyMem)
|
||||||
|
doAssert x.T is string # true
|
||||||
|
doAssert x.raw_buffer is seq
|
||||||
Loading…
Add table
Add a link
Reference in a new issue