hasCustomPragmaFixed supports types with quoted field names

This commit is contained in:
Zahary Karadjov 2019-07-31 02:43:35 +03:00
parent e203f709d6
commit 2ca2f25af6
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 4 additions and 1 deletions

View File

@ -131,7 +131,10 @@ macro hasCustomPragmaFixed*(T: type, field: static string, pragma: typed{nkSym})
Timpl = getImpl(Tresolved) Timpl = getImpl(Tresolved)
for f in recordFields(Timpl): for f in recordFields(Timpl):
if eqIdent(f.name, field): var fieldName = f.name
# TODO: Fix this in eqIdent
if fieldName.kind == nnkAccQuoted: fieldName = fieldName[0]
if eqIdent(fieldName, field):
return newLit(f.pragmas.findPragma(pragma) != nil) return newLit(f.pragmas.findPragma(pragma) != nil)
error "The type " & $Tresolved & " doesn't have a field named " & field error "The type " & $Tresolved & " doesn't have a field named " & field