From 86298e30d97944752b5ba11fcbaeb0d6666bb613 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Mon, 21 Dec 2020 17:05:21 -0800 Subject: [PATCH] [backport => 1.0] fix #16428 vmops now works for generic procs (#16429) * fix #16428 vmops now works for generic procs * remove duplication (cherry picked from commit bc84d9c8cbaf4700e7c984a50876553ec21168b0) --- compiler/vmgen.nim | 14 ++------------ tests/vm/tvmops.nim | 4 ++++ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index 3db143280c..c25d31d15d 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -1957,16 +1957,6 @@ proc genProc*(c: PCtx; s: PSym): int proc matches(s: PSym; x: string): bool = let y = x.split('.') - var s = s - var L = y.len-1 - while L >= 0: - if s == nil or (y[L].cmpIgnoreStyle(s.name.s) != 0 and y[L] != "*"): - return false - s = s.owner - dec L - result = true - -proc matches(s: PSym; y: varargs[string]): bool = var s = s var L = y.len-1 while L >= 0: @@ -2029,11 +2019,11 @@ proc gen(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags = {}) = elif s.kind == skMethod: localError(c.config, n.info, "cannot call method " & s.name.s & " at compile time") - elif matches(s, "stdlib", "marshal", "to"): + elif matches(s, "stdlib.marshal.to"): # XXX marshal load&store should not be opcodes, but use the # general callback mechanisms. genMarshalLoad(c, n, dest) - elif matches(s, "stdlib", "marshal", "$$"): + elif matches(s, "stdlib.marshal.$$"): genMarshalStore(c, n, dest) else: genCall(c, n, dest) diff --git a/tests/vm/tvmops.nim b/tests/vm/tvmops.nim index 6442c49d6f..c8febd9820 100644 --- a/tests/vm/tvmops.nim +++ b/tests/vm/tvmops.nim @@ -1,3 +1,7 @@ +discard """ + targets: "c cpp js" +""" + #[ test for vmops.nim ]#