Co-authored-by: cooldome <ariabushenko@bk.ru>
This commit is contained in:
parent
814f150184
commit
8ba915e449
2 changed files with 20 additions and 0 deletions
|
|
@ -189,6 +189,11 @@ proc isCastable(conf: ConfigRef; dst, src: PType): bool =
|
||||||
return false
|
return false
|
||||||
if skipTypes(src, abstractInst-{tyTypeDesc}).kind == tyTypeDesc:
|
if skipTypes(src, abstractInst-{tyTypeDesc}).kind == tyTypeDesc:
|
||||||
return false
|
return false
|
||||||
|
if conf.selectedGC in {gcArc, gcOrc}:
|
||||||
|
let d = skipTypes(dst, abstractInst)
|
||||||
|
let s = skipTypes(src, abstractInst)
|
||||||
|
if d.kind == tyRef and s.kind == tyRef and s[0].isFinal != d[0].isFinal:
|
||||||
|
return false
|
||||||
|
|
||||||
var dstSize, srcSize: BiggestInt
|
var dstSize, srcSize: BiggestInt
|
||||||
dstSize = computeSize(conf, dst)
|
dstSize = computeSize(conf, dst)
|
||||||
|
|
|
||||||
15
tests/arc/tref_cast_error.nim
Normal file
15
tests/arc/tref_cast_error.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
discard """
|
||||||
|
cmd: "nim c --gc:arc $file"
|
||||||
|
errormsg: "expression cannot be cast to ref RootObj"
|
||||||
|
joinable: false
|
||||||
|
"""
|
||||||
|
|
||||||
|
type Variant* = object
|
||||||
|
refval: ref RootObj
|
||||||
|
|
||||||
|
proc newVariant*[T](val: T): Variant =
|
||||||
|
let pt = T.new()
|
||||||
|
pt[] = val
|
||||||
|
result = Variant(refval: cast[ref RootObj](pt))
|
||||||
|
|
||||||
|
var v = newVariant(@[1, 2, 3])
|
||||||
Loading…
Add table
Add a link
Reference in a new issue