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>
This commit is contained in:
Saem Ghani 2021-02-15 00:51:05 -08:00 • committed by GitHub
commit 260a5dacb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 24 deletions

View file

@ -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)