support multiple nim version re. nnkArgList issue

This commit is contained in:
jangko 2022-09-22 08:16:32 +07:00
parent 0c379cf1d8
commit f2e58ba4c8
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 13 additions and 19 deletions

View File

@ -12,31 +12,17 @@ requires "nim >= 1.2.0",
### Helper functions ### Helper functions
proc test(args, path: string) = proc test(args, path: string) =
# nnkArglist was changed to nnkArgList, so can't always use --styleCheck:error
# https://github.com/nim-lang/Nim/pull/17529
# https://github.com/nim-lang/Nim/pull/19822
let styleCheckStyle =
if (NimMajor, NimMinor) < (1, 6):
"hint"
else:
"error"
# Compilation language is controlled by TEST_LANG # Compilation language is controlled by TEST_LANG
exec "nim " & getEnv("TEST_LANG", "c") & " " & getEnv("NIMFLAGS") & exec "nim " & getEnv("TEST_LANG", "c") & " " & getEnv("NIMFLAGS") &
" " & args & " " & args &
" -r --hints:off --skipParentCfg --styleCheck:usages --styleCheck:" & " -r --hints:off --skipParentCfg --styleCheck:usages --styleCheck:error" &
styleCheckStyle & " " & path " " & path
proc buildHelper(args, path: string) = proc buildHelper(args, path: string) =
let styleCheckStyle =
if (NimMajor, NimMinor) < (1, 6):
"hint"
else:
"error"
exec "nim " & getEnv("TEST_LANG", "c") & " " & getEnv("NIMFLAGS") & exec "nim " & getEnv("TEST_LANG", "c") & " " & getEnv("NIMFLAGS") &
" " & args & " " & args &
" --hints:off --skipParentCfg --styleCheck:usages --styleCheck:" & " --hints:off --skipParentCfg --styleCheck:usages --styleCheck:error" &
styleCheckStyle & " " & path " " & path
task test, "Run all tests": task test, "Run all tests":
# Building `test_helper.nim`. # Building `test_helper.nim`.

View File

@ -414,11 +414,19 @@ iterator baseTypes*(exceptionType: NimNode): NimNode =
yield typ yield typ
macro unpackArgs*(callee: untyped, args: untyped): untyped = macro unpackArgs*(callee: untyped, args: untyped): untyped =
# nnkArglist was changed to nnkArgList
# https://github.com/nim-lang/Nim/pull/17529
# https://github.com/nim-lang/Nim/pull/19822
const ArgKind = when (NimMajor, NimMinor) < (1, 6):
nnkArglist
else:
nnkArgList
result = newCall(callee) result = newCall(callee)
for arg in args: for arg in args:
let arg = if arg.kind == nnkHiddenStdConv: arg[1] let arg = if arg.kind == nnkHiddenStdConv: arg[1]
else: arg else: arg
if arg.kind == nnkArgList: if arg.kind == ArgKind:
for subarg in arg: for subarg in arg:
result.add subarg result.add subarg
else: else: