summary refs log tree commit diff stats
path: root/compiler/vmgen.nim
diff options
context:
space:
mode:
authorSaem Ghani <saemghani+github@gmail.com>2021-02-15 00:51:05 -0800
committerGitHub <noreply@github.com>2021-02-15 09:51:05 +0100
commit260a5dacb7a3854d6d6aa18d9996b88bfcd13cc6 (patch)
tree175b30daf8594641e5f47e0576914e73fd386594 /compiler/vmgen.nim
parentb68ecc82cb404dbbd291320139955794e88c24ff (diff)
downloadNim-260a5dacb7a3854d6d6aa18d9996b88bfcd13cc6.tar.gz
fixed dot operator recursive loop & macro suggest (#16922)
* basic stability improvements; refs nimsuggest
* fixed dot operator recursive loop & macro suggest
* hacky fix for run away dot operator sem check

Committing this mostly to make the issue more clear. Perhaps get better
feedback.

* semExprWithType seems like a better place to check
* fixed error messages const case expressions
* Clean-up test
* stopped the dot operator madness

No longer get infinite recursion when seming broken code with a dot
operator macro like in jsffi.

Co-authored-by: Araq <rumpf_a@web.de>
Diffstat (limited to 'compiler/vmgen.nim')
-rw-r--r--compiler/vmgen.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim
index 6790276a9..d74bd44d8 100644
--- a/compiler/vmgen.nim
+++ b/compiler/vmgen.nim
@@ -505,7 +505,10 @@ proc genCase(c: PCtx; n: PNode; dest: var TDest) =
       let it = n[i]
       if it.len == 1:
         # else stmt:
-        c.gen(it[0], dest)
+        if it[0].kind != nkNilLit or it[0].typ != nil:
+          # an nkNilLit with nil for typ implies there is no else branch, this
+          # avoids unused related errors as we've already consumed the dest
+          c.gen(it[0], dest)
       else:
         let b = rawGenLiteral(c, it)
         c.gABx(it, opcBranch, tmp, b)