fixes #23355; pop optionStack when exiting scopes (#24926)

fixes #23355
This commit is contained in:
ringabout
2025-05-04 09:29:59 +08:00
committed by GitHub
parent f56568d851
commit 98ec87d65e
3 changed files with 16 additions and 1 deletions

View File

@@ -684,6 +684,7 @@ type
symbols*: TStrTable
parent*: PScope
allowPrivateAccess*: seq[PSym] # # enable access to private fields
optionStackLen*: int
PScope* = ref TScope

View File

@@ -75,10 +75,13 @@ proc addUniqueSym*(scope: PScope, s: PSym): PSym =
proc openScope*(c: PContext): PScope {.discardable.} =
result = PScope(parent: c.currentScope,
symbols: initStrTable(),
depthLevel: c.scopeDepth + 1)
depthLevel: c.scopeDepth + 1,
optionStackLen: c.optionStack.len)
c.currentScope = result
proc rawCloseScope*(c: PContext) =
if c.currentScope.optionStackLen >= 1:
c.optionStack.setLen(c.currentScope.optionStackLen)
c.currentScope = c.currentScope.parent
proc closeScope*(c: PContext) =