fix #49: field type with qualified ident

This commit is contained in:
jangko 2022-05-10 11:58:13 +07:00
parent 8f8f715f76
commit d06f6187dc
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
4 changed files with 31 additions and 2 deletions

View File

@ -148,7 +148,7 @@ proc traverseIdentDefs(identDefs: NimNode, parent: ConfFileSection,
result.add traversePostfix(child, typ, isDiscriminator) result.add traversePostfix(child, typ, isDiscriminator)
of nnkPragmaExpr: of nnkPragmaExpr:
result.add traversePragmaExpr(child, typ, isDiscriminator) result.add traversePragmaExpr(child, typ, isDiscriminator)
of nnkBracketExpr, nnkSym, nnkEmpty, nnkInfix, nnkCall: of nnkBracketExpr, nnkSym, nnkEmpty, nnkInfix, nnkCall, nnkDotExpr:
discard discard
else: else:
raiseAssert "[IdentDefs] Unsupported child node:\n" & child.treeRepr raiseAssert "[IdentDefs] Unsupported child node:\n" & child.treeRepr

2
tests/specialint.nim Normal file
View File

@ -0,0 +1,2 @@
type
SInt* = distinct int

View File

@ -12,7 +12,8 @@ import
test_config_file, test_config_file,
test_envvar, test_envvar,
test_parsecmdarg, test_parsecmdarg,
test_pragma test_pragma,
test_qualified_ident
when defined(windows): when defined(windows):
import test_winreg import test_winreg

View File

@ -0,0 +1,26 @@
import
std/[strutils, unittest],
../confutils,
./specialint
type
TestConf* = object
La1* {.
desc: "La1"
name: "la1" }: SInt
La2* {.
desc: "La2"
name: "la2" }: specialint.SInt
proc parseCmdArg(T: type specialint.SInt, p: TaintedString): T =
parseInt(string p).T
proc completeCmdArg(T: type specialint.SInt, val: TaintedString): seq[string] =
return @[]
suite "Qualified Ident":
test "Qualified Ident":
let conf = TestConf.load(@["--la1:123", "--la2:456"])
check conf.La1.int == 123
check conf.La2.int == 456