From d06f6187dca702ad884b9b948f52b26bf6596765 Mon Sep 17 00:00:00 2001 From: jangko Date: Tue, 10 May 2022 11:58:13 +0700 Subject: [PATCH] fix #49: field type with qualified ident --- confutils/config_file.nim | 2 +- tests/specialint.nim | 2 ++ tests/test_all.nim | 3 ++- tests/test_qualified_ident.nim | 26 ++++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 tests/specialint.nim create mode 100644 tests/test_qualified_ident.nim diff --git a/confutils/config_file.nim b/confutils/config_file.nim index 84f28fa..8a62af1 100644 --- a/confutils/config_file.nim +++ b/confutils/config_file.nim @@ -148,7 +148,7 @@ proc traverseIdentDefs(identDefs: NimNode, parent: ConfFileSection, result.add traversePostfix(child, typ, isDiscriminator) of nnkPragmaExpr: result.add traversePragmaExpr(child, typ, isDiscriminator) - of nnkBracketExpr, nnkSym, nnkEmpty, nnkInfix, nnkCall: + of nnkBracketExpr, nnkSym, nnkEmpty, nnkInfix, nnkCall, nnkDotExpr: discard else: raiseAssert "[IdentDefs] Unsupported child node:\n" & child.treeRepr diff --git a/tests/specialint.nim b/tests/specialint.nim new file mode 100644 index 0000000..0017782 --- /dev/null +++ b/tests/specialint.nim @@ -0,0 +1,2 @@ +type + SInt* = distinct int diff --git a/tests/test_all.nim b/tests/test_all.nim index 32bd8d6..9b429e4 100644 --- a/tests/test_all.nim +++ b/tests/test_all.nim @@ -12,7 +12,8 @@ import test_config_file, test_envvar, test_parsecmdarg, - test_pragma + test_pragma, + test_qualified_ident when defined(windows): import test_winreg diff --git a/tests/test_qualified_ident.nim b/tests/test_qualified_ident.nim new file mode 100644 index 0000000..3eabed5 --- /dev/null +++ b/tests/test_qualified_ident.nim @@ -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