diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-09-18 10:29:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-18 10:29:49 +0200 |
commit | a5d014233a1334ef2a8f11efd86d74fd332cddf6 (patch) | |
tree | a5b61211611447151b76a4a2f4d348039bab1b9d | |
parent | aa2d219afe8592d3764f73e8771d1e13ac5ea55b (diff) | |
parent | c2e5faf959f006af67d1a054a92096d63eae192a (diff) | |
download | Nim-a5d014233a1334ef2a8f11efd86d74fd332cddf6.tar.gz |
Merge pull request #8996 from LemonBoy/fix-2574
The VM cannot call methods
-rw-r--r-- | compiler/vmgen.nim | 3 | ||||
-rw-r--r-- | tests/vm/t2574.nim | 14 |
2 files changed, 17 insertions, 0 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index e87347ec8..b6b5bf4f2 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -1842,6 +1842,9 @@ proc gen(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags = {}) = let s = n.sons[0].sym if s.magic != mNone: genMagic(c, n, dest, s.magic) + elif s.kind == skMethod: + localError(c.config, n.info, "cannot call method " & s.name.s & + " at compile time") elif matches(s, "stdlib", "marshal", "to"): # XXX marshal load&store should not be opcodes, but use the # general callback mechanisms. diff --git a/tests/vm/t2574.nim b/tests/vm/t2574.nim new file mode 100644 index 000000000..86602aeaf --- /dev/null +++ b/tests/vm/t2574.nim @@ -0,0 +1,14 @@ +discard """ + line: 14 + errormsg: "cannot call method eval at compile time" +""" + +type + PExpr = ref object of RootObj + +method eval(e: PExpr): int = + discard + +static: + let x = PExpr() + discard x.eval |