require secondarySources to be gcsafe (#86)

Avoid Nim 2.0 warning in callers of `confutils.load`.

```
Warning: 'loadImpl' is not GC-safe as it performs an indirect call via 'secondarySources' [GcUnsafe2]
```
This commit is contained in:
Etan Kissling 2023-07-31 14:56:44 +02:00 committed by GitHub
parent c67257660b
commit dbe8d61f7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -893,7 +893,7 @@ proc loadImpl[C, SecondarySources](
quitOnFailure = true, quitOnFailure = true,
secondarySourcesRef: ref SecondarySources, secondarySourcesRef: ref SecondarySources,
secondarySources: proc (config: Configuration, secondarySources: proc (config: Configuration,
sources: ref SecondarySources) = nil, sources: ref SecondarySources) {.gcsafe.} = nil,
envVarsPrefix = getAppFilename()): Configuration = envVarsPrefix = getAppFilename()): Configuration =
## Loads a program configuration by parsing command-line arguments ## Loads a program configuration by parsing command-line arguments
## and a standard set of config files that can specify: ## and a standard set of config files that can specify:

View File

@ -182,7 +182,11 @@ proc testConfigFile() =
putEnv("PREFIX_DATA_DIR", "ENV VAR DATADIR") putEnv("PREFIX_DATA_DIR", "ENV VAR DATADIR")
test "basic config file": test "basic config file":
let conf = TestConf.load(envVarsPrefix="prefix", secondarySources = proc (config: TestConf, sources: auto) = let conf = TestConf.load(
envVarsPrefix="prefix",
secondarySources = proc (
config: TestConf, sources: ref SecondarySources
) {.raises: [ConfigurationError].} =
if config.configFile.isSome: if config.configFile.isSome:
sources.addConfigFile(Toml, config.configFile.get) sources.addConfigFile(Toml, config.configFile.get)
else: else: