fix #14007 (#14012) [backport]

Co-authored-by: cooldome <ariabushenko@bk.ru>
This commit is contained in:
cooldome
2020-04-18 15:15:17 +01:00
committed by GitHub
parent f10689d3d4
commit d839eb9352
2 changed files with 15 additions and 2 deletions

View File

@@ -722,7 +722,11 @@ proc getConstExpr(m: PSym, n: PNode; g: ModuleGraph): PNode =
of nkBracketExpr: result = foldArrayAccess(m, n, g)
of nkDotExpr: result = foldFieldAccess(m, n, g)
of nkStmtListExpr:
if n.len == 2 and n[0].kind == nkComesFrom:
result = getConstExpr(m, n[1], g)
var i = 0
while i <= n.len - 2:
if n[i].kind in {nkComesFrom, nkCommentStmt, nkEmpty}: i.inc
else: break
if i == n.len - 1:
result = getConstExpr(m, n[i], g)
else:
discard

View File

@@ -30,3 +30,12 @@ const
}.toTable
#map["test"]()
#-------------------------------------------------------------------
# bug
const val = 10
type
t = object
when val >= 10:
a: int