diff options
author | Yuriy Glukhov <yuriy.glukhov@gmail.com> | 2016-07-06 14:39:42 +0300 |
---|---|---|
committer | Yuriy Glukhov <yuriy.glukhov@gmail.com> | 2016-07-06 14:39:57 +0300 |
commit | 09783c3fd0cb98c08aa65d27a3fa630cdc99b673 (patch) | |
tree | 8cc567f66bc3899700e14836ff2ad3538fae001b | |
parent | b681e91745a49944e8429b79a1895f850b7e5762 (diff) | |
download | Nim-09783c3fd0cb98c08aa65d27a3fa630cdc99b673.tar.gz |
Fixed vm codegen for a call with compile-time args. Fixes #4412.
-rw-r--r-- | compiler/vmgen.nim | 5 | ||||
-rw-r--r-- | tests/vm/tvmmisc.nim | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index d4966b3e3..c63182b0c 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -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: diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim new file mode 100644 index 000000000..e935013c4 --- /dev/null +++ b/tests/vm/tvmmisc.nim @@ -0,0 +1,6 @@ + +# 4412 +proc default[T](t: typedesc[T]): T {.inline.} = discard + +static: + var x = default(type(0)) |