Fixed vm codegen for a call with compile-time args. Fixes #4412.

This commit is contained in:
Yuriy Glukhov
2016-07-06 14:39:42 +03:00
parent b681e91745
commit 09783c3fd0
2 changed files with 10 additions and 1 deletions

View File

@@ -501,8 +501,11 @@ proc genCall(c: PCtx; n: PNode; dest: var TDest) =
if dest < 0 and not isEmptyType(n.typ): dest = getTemp(c, n.typ)
let x = c.getTempRange(n.len, slotTempUnknown)
# varargs need 'opcSetType' for the FFI support:
let fntyp = n.sons[0].typ
let fntyp = skipTypes(n.sons[0].typ, abstractInst)
for i in 0.. <n.len:
if i > 0 and i < sonsLen(fntyp):
let paramType = fntyp.n.sons[i]
if paramType.typ.isCompileTimeOnly: continue
var r: TRegister = x+i
c.gen(n.sons[i], r)
if i >= fntyp.len:

6
tests/vm/tvmmisc.nim Normal file
View File

@@ -0,0 +1,6 @@
# 4412
proc default[T](t: typedesc[T]): T {.inline.} = discard
static:
var x = default(type(0))