fixes #22212; Compile error when running a Nimscript that compares se… (#22213)

fixes #22212; Compile error when running a Nimscript that compares seq with switch("mm", "arc")
This commit is contained in:
ringabout
2023-07-03 20:15:44 +08:00
committed by GitHub
parent d9a24b9b81
commit c513e37a70
2 changed files with 16 additions and 4 deletions

View File

@@ -527,10 +527,11 @@ proc registerArcOrc(pass: TCmdLinePass, conf: ConfigRef) =
if conf.exc == excNone and conf.backend != backendCpp:
conf.exc = excGoto
proc unregisterArcOrc(conf: ConfigRef) =
proc unregisterArcOrc*(conf: ConfigRef) =
undefSymbol(conf.symbols, "gcdestructors")
undefSymbol(conf.symbols, "gcarc")
undefSymbol(conf.symbols, "gcorc")
undefSymbol(conf.symbols, "gcatomicarc")
undefSymbol(conf.symbols, "nimSeqsV2")
undefSymbol(conf.symbols, "nimV2")
excl conf.globalOptions, optSeqDestructors

View File

@@ -17,7 +17,7 @@ import
pathutils, pipelines
when defined(nimPreviewSlimSystem):
import std/syncio
import std/[syncio, assertions]
# we support 'cmpIgnoreStyle' natively for efficiency:
from strutils import cmpIgnoreStyle, contains
@@ -207,8 +207,8 @@ proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
let oldGlobalOptions = conf.globalOptions
let oldSelectedGC = conf.selectedGC
undefSymbol(conf.symbols, "nimv2")
conf.globalOptions.excl {optTinyRtti, optOwnedRefs, optSeqDestructors}
unregisterArcOrc(conf)
conf.globalOptions.excl optOwnedRefs
conf.selectedGC = gcUnselected
var m = graph.makeModule(scriptName)
@@ -230,6 +230,17 @@ proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
if conf.selectedGC in {gcArc, gcOrc, gcAtomicArc}:
conf.globalOptions.incl {optTinyRtti, optSeqDestructors}
defineSymbol(conf.symbols, "nimv2")
defineSymbol(conf.symbols, "gcdestructors")
defineSymbol(conf.symbols, "nimSeqsV2")
case conf.selectedGC
of gcArc:
defineSymbol(conf.symbols, "gcarc")
of gcOrc:
defineSymbol(conf.symbols, "gcorc")
of gcAtomicArc:
defineSymbol(conf.symbols, "gcatomicarc")
else:
doAssert false, "unreachable"
# ensure we load 'system.nim' again for the real non-config stuff!
resetSystemArtifacts(graph)