fixes #12488 [backport]

(cherry picked from commit 87f0d534d6)
This commit is contained in:
Araq
2019-11-28 10:11:25 +01:00
committed by narimiran
parent a02a4d8fc5
commit 299f1e99cd
2 changed files with 21 additions and 1 deletions

View File

@@ -2130,7 +2130,10 @@ proc gen(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags = {}) =
of nkComesFrom:
discard "XXX to implement for better stack traces"
else:
globalError(c.config, n.info, "cannot generate VM code for " & $n)
if n.typ != nil and n.typ.isCompileTimeOnly:
genTypeLit(c, n.typ, dest)
else:
globalError(c.config, n.info, "cannot generate VM code for " & $n)
proc removeLastEof(c: PCtx) =
let last = c.code.len-1

View File

@@ -15,6 +15,9 @@ Done!
foo4
foo4
foo4
(a: 0, b: 0)
(a: 0, b: 0)
(a: 0, b: 0)
'''
"""
@@ -234,3 +237,17 @@ static:
echo foo()
echo foo()
echo foo()
# bug #12488
type
MyObject = object
a,b: int
MyObjectRef = ref MyObject
static:
let x1 = new(MyObject)
echo x1[]
let x2 = new(MyObjectRef)
echo x2[]
let x3 = new(ref MyObject) # cannot generate VM code for ref MyObject
echo x3[]