Skip to content

some issues with hasCustomPragma/recordFields #12

@jangko

Description

@jangko
  1. getType(T)[1].getImpl will not work on ref type including deref version like type(default(someref)[]).

possible work around. after getType, use new owner API then symKind and typeKind to check if it has parent type or something else.

nim-confutils, nim-serialization, and nim-json-serialization suffer from this problem too.

  1. nnkPragma and nnkPosfix in recordFields
          if field.name.kind == nnkPragmaExpr:
            field.pragmas = field.name[1]
            field.name = field.name[0]

          if field.name.kind == nnkPostfix:
            field.isPublic = true
            field.name = field.name[1]

this is clearly wrong, nnkPostFix will appear inside nnkPragmaExpr in the AST. need fix

  1. using nnkRecWhen in recordFields can leads to unexpected result. should use semchecked AST of getType instead of raw AST from getImpl.

nnkRecWhen will not appear at final type, only branch evaluated to true will appear at final type. if we use nnkRecWhen, both false branch and true branch will have conflict if they contains fields with same name. false branch existence also posses it's own problem if we count the field number or enumerate the fields.

work around: not known, getType and friends return an AST without pragmas. need to patch the getType family.

related: nim-lang/RFCs#176

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions