mirror of
https://github.com/nim-lang/Nim.git
synced 2026-05-25 22:38:15 +00:00
fix #25732
This commit is contained in:
@@ -963,12 +963,15 @@ proc evalAtCompileTime(c: PContext, n: PNode): PNode =
|
||||
# echo "SUCCESS evaluated at compile time: ", call.renderTree
|
||||
|
||||
proc semStaticExpr(c: PContext, n: PNode; expectedType: PType = nil): PNode =
|
||||
let oldErrorCount = c.config.errorCounter
|
||||
inc c.inStaticContext
|
||||
openScope(c)
|
||||
let a = semExprWithType(c, n, expectedType = expectedType)
|
||||
closeScope(c)
|
||||
dec c.inStaticContext
|
||||
if a.findUnresolvedStatic != nil: return a
|
||||
if a.findUnresolvedStatic != nil or
|
||||
c.config.errorCounter != oldErrorCount:
|
||||
return a
|
||||
result = evalStaticExpr(c.module, c.idgen, c.graph, a, c.p.owner)
|
||||
if result.isNil:
|
||||
localError(c.config, n.info, errCannotInterpretNodeX % renderTree(n))
|
||||
|
||||
@@ -2919,13 +2919,15 @@ proc semPragmaBlock(c: PContext, n: PNode; expectedType: PType = nil): PNode =
|
||||
proc semStaticStmt(c: PContext, n: PNode): PNode =
|
||||
#echo "semStaticStmt"
|
||||
#writeStackTrace()
|
||||
let oldErrorCount = c.config.errorCounter
|
||||
inc c.inStaticContext
|
||||
openScope(c)
|
||||
let a = semStmt(c, n[0], {})
|
||||
closeScope(c)
|
||||
dec c.inStaticContext
|
||||
n[0] = a
|
||||
evalStaticStmt(c.module, c.idgen, c.graph, a, c.p.owner)
|
||||
if c.config.errorCounter == oldErrorCount:
|
||||
evalStaticStmt(c.module, c.idgen, c.graph, a, c.p.owner)
|
||||
when false:
|
||||
# for incremental replays, keep the AST as required for replays:
|
||||
result = n
|
||||
|
||||
15
tests/errmsgs/t25732.nim
Normal file
15
tests/errmsgs/t25732.nim
Normal file
@@ -0,0 +1,15 @@
|
||||
discard """
|
||||
cmd: "nim check --hints:off $file"
|
||||
action: "reject"
|
||||
nimout: '''
|
||||
t25732.nim(15, 32) Error: undeclared identifier: 'a'
|
||||
t25732.nim(15, 32) Error: expression 'a' has no type (or is ambiguous)
|
||||
t25732.nim(15, 33) Error: undeclared field: 'b'
|
||||
t25732.nim(15, 33) Error: undeclared field: '.'
|
||||
t25732.nim(15, 33) Error: undeclared field: '.'
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
|
||||
static: (for f in [0]: discard a.b == f)
|
||||
Reference in New Issue
Block a user