avoid Nim 2.0 issue when loading config (#5202)
To avoid Nim 2.0 issue https://github.com/nim-lang/Nim/issues/22284, explicitly specify `ref SecondarySources` instead of using `auto`, and add `{.raises.}` annotation
This commit is contained in:
parent
3eb1729d15
commit
da5bb96856
|
@ -201,7 +201,7 @@ template makeBannerAndConfig*(clientId: string, ConfType: type): untyped =
|
||||||
version = version, # but a short version string makes more sense...
|
version = version, # but a short version string makes more sense...
|
||||||
copyrightBanner = clientId,
|
copyrightBanner = clientId,
|
||||||
secondarySources = proc (
|
secondarySources = proc (
|
||||||
config: ConfType, sources: auto
|
config: ConfType, sources: ref SecondarySources
|
||||||
) {.raises: [ConfigurationError].} =
|
) {.raises: [ConfigurationError].} =
|
||||||
if config.configFile.isSome:
|
if config.configFile.isSome:
|
||||||
sources.addConfigFile(Toml, config.configFile.get)
|
sources.addConfigFile(Toml, config.configFile.get)
|
||||||
|
|
|
@ -82,6 +82,8 @@ proc main(flags: CliFlags) {.async.} =
|
||||||
|
|
||||||
waitFor main(
|
waitFor main(
|
||||||
load(CliFlags,
|
load(CliFlags,
|
||||||
secondarySources = proc (config: CliFlags, sources: auto) =
|
secondarySources = proc (
|
||||||
|
config: CliFlags, 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)))
|
||||||
|
|
|
@ -21,7 +21,9 @@ type
|
||||||
proc loadExampleConfig(content: string, cmdLine = newSeq[string]()): ExampleConfigFile =
|
proc loadExampleConfig(content: string, cmdLine = newSeq[string]()): ExampleConfigFile =
|
||||||
ExampleConfigFile.load(
|
ExampleConfigFile.load(
|
||||||
cmdLine = cmdLine,
|
cmdLine = cmdLine,
|
||||||
secondarySources = proc (config: ExampleConfigFile, sources: auto) =
|
secondarySources = proc (
|
||||||
|
config: ExampleConfigFile, sources: ref SecondarySources
|
||||||
|
) {.raises: [ConfigurationError].} =
|
||||||
sources.addConfigFileContent(Toml, content))
|
sources.addConfigFileContent(Toml, content))
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
Loading…
Reference in New Issue