mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-09 06:23:25 +00:00
Allow nnkAccQuoted in genEnumCaseStmt (#18606)
* [enumutils] provide node kind for `Invalid node type` error * [enumutils] add support for nnkAccQuoted in `genEnumCaseStmt` For reasons unknown to me, when running `nim doc` on a file that uses `parseEnum` with an enum that contains accented quotes errors at CT with the `Invalid node for type` error. Further errors are raised, probably because the enum parsing fails?
This commit is contained in:
@@ -36,6 +36,10 @@ macro genEnumCaseStmt*(typ: typedesc, argSym: typed, default: typed,
|
||||
case f.kind
|
||||
of nnkEmpty: continue # skip first node of `enumTy`
|
||||
of nnkSym, nnkIdent: fStr = f.strVal
|
||||
of nnkAccQuoted:
|
||||
fStr = ""
|
||||
for ch in f:
|
||||
fStr.add ch.strVal
|
||||
of nnkEnumFieldDef:
|
||||
case f[1].kind
|
||||
of nnkStrLit: fStr = f[1].strVal
|
||||
@@ -46,7 +50,7 @@ macro genEnumCaseStmt*(typ: typedesc, argSym: typed, default: typed,
|
||||
fStr = f[0].strVal
|
||||
fNum = f[1].intVal
|
||||
else: error("Invalid tuple syntax!", f[1])
|
||||
else: error("Invalid node for enum type!", f)
|
||||
else: error("Invalid node for enum type `" & $f.kind & "`!", f)
|
||||
# add field if string not already added
|
||||
if fNum >= userMin and fNum <= userMax:
|
||||
fStr = normalizer(fStr)
|
||||
|
||||
Reference in New Issue
Block a user