tincompletecaseobject.nim 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. discard """
  2. errormsg: '''
  3. not all cases are covered; missing: {nnkComesFrom, nnkDotCall, nnkHiddenCallConv, nnkVarTuple, nnkCurlyExpr, nnkRange, nnkCheckedFieldExpr, nnkDerefExpr, nnkElifExpr, nnkElseExpr, nnkLambda, nnkDo, nnkBind, nnkClosedSymChoice, nnkHiddenSubConv, nnkConv, nnkStaticExpr, nnkAddr, nnkHiddenAddr, nnkHiddenDeref, nnkObjDownConv, nnkObjUpConv, nnkChckRangeF, nnkChckRange64, nnkChckRange, nnkStringToCString, nnkCStringToString, nnkFastAsgn, nnkGenericParams, nnkFormalParams, nnkOfInherit, nnkImportAs, nnkConverterDef, nnkMacroDef, nnkTemplateDef, nnkIteratorDef, nnkOfBranch, nnkElifBranch, nnkExceptBranch, nnkElse, nnkAsmStmt, nnkTypeDef, nnkFinally, nnkContinueStmt, nnkImportStmt, nnkImportExceptStmt, nnkExportStmt, nnkExportExceptStmt, nnkFromStmt, nnkIncludeStmt, nnkUsingStmt, nnkBlockExpr, nnkStmtListType, nnkBlockType, nnkWith, nnkWithout, nnkTypeOfExpr, nnkObjectTy, nnkTupleTy, nnkTupleClassTy, nnkTypeClassTy, nnkStaticTy, nnkRecList, nnkRecCase, nnkRecWhen, nnkVarTy, nnkConstTy, nnkMutableTy, nnkDistinctTy, nnkProcTy, nnkIteratorTy, nnkSharedTy, nnkEnumTy, nnkEnumFieldDef, nnkArglist, nnkPattern, nnkReturnToken, nnkClosure, nnkGotoState, nnkState, nnkBreakState, nnkFuncDef, nnkTupleConstr}
  4. '''
  5. """
  6. # this isn't imported from macros.nim to make it robust against possible changes in the ast.
  7. type
  8. NimNodeKind* = enum
  9. nnkNone, nnkEmpty, nnkIdent, nnkSym,
  10. nnkType, nnkCharLit, nnkIntLit, nnkInt8Lit,
  11. nnkInt16Lit, nnkInt32Lit, nnkInt64Lit, nnkUIntLit, nnkUInt8Lit,
  12. nnkUInt16Lit, nnkUInt32Lit, nnkUInt64Lit, nnkFloatLit,
  13. nnkFloat32Lit, nnkFloat64Lit, nnkFloat128Lit, nnkStrLit, nnkRStrLit,
  14. nnkTripleStrLit, nnkNilLit, nnkComesFrom, nnkDotCall,
  15. nnkCommand, nnkCall, nnkCallStrLit, nnkInfix,
  16. nnkPrefix, nnkPostfix, nnkHiddenCallConv,
  17. nnkExprEqExpr,
  18. nnkExprColonExpr, nnkIdentDefs, nnkVarTuple,
  19. nnkPar, nnkObjConstr, nnkCurly, nnkCurlyExpr,
  20. nnkBracket, nnkBracketExpr, nnkPragmaExpr, nnkRange,
  21. nnkDotExpr, nnkCheckedFieldExpr, nnkDerefExpr, nnkIfExpr,
  22. nnkElifExpr, nnkElseExpr, nnkLambda, nnkDo, nnkAccQuoted,
  23. nnkTableConstr, nnkBind,
  24. nnkClosedSymChoice,
  25. nnkOpenSymChoice,
  26. nnkHiddenStdConv,
  27. nnkHiddenSubConv, nnkConv, nnkCast, nnkStaticExpr,
  28. nnkAddr, nnkHiddenAddr, nnkHiddenDeref, nnkObjDownConv,
  29. nnkObjUpConv, nnkChckRangeF, nnkChckRange64, nnkChckRange,
  30. nnkStringToCString, nnkCStringToString, nnkAsgn,
  31. nnkFastAsgn, nnkGenericParams, nnkFormalParams, nnkOfInherit,
  32. nnkImportAs, nnkProcDef, nnkMethodDef, nnkConverterDef,
  33. nnkMacroDef, nnkTemplateDef, nnkIteratorDef, nnkOfBranch,
  34. nnkElifBranch, nnkExceptBranch, nnkElse,
  35. nnkAsmStmt, nnkPragma, nnkPragmaBlock, nnkIfStmt, nnkWhenStmt,
  36. nnkForStmt, nnkParForStmt, nnkWhileStmt, nnkCaseStmt,
  37. nnkTypeSection, nnkVarSection, nnkLetSection, nnkConstSection,
  38. nnkConstDef, nnkTypeDef,
  39. nnkYieldStmt, nnkDefer, nnkTryStmt, nnkFinally, nnkRaiseStmt,
  40. nnkReturnStmt, nnkBreakStmt, nnkContinueStmt, nnkBlockStmt, nnkStaticStmt,
  41. nnkDiscardStmt, nnkStmtList,
  42. nnkImportStmt = 1337, # make a hole just for fun
  43. nnkImportExceptStmt,
  44. nnkExportStmt,
  45. nnkExportExceptStmt,
  46. nnkFromStmt,
  47. nnkIncludeStmt,
  48. nnkBindStmt, nnkMixinStmt, nnkUsingStmt,
  49. nnkCommentStmt, nnkStmtListExpr, nnkBlockExpr,
  50. nnkStmtListType, nnkBlockType,
  51. nnkWith, nnkWithout,
  52. nnkTypeOfExpr, nnkObjectTy,
  53. nnkTupleTy, nnkTupleClassTy, nnkTypeClassTy, nnkStaticTy,
  54. nnkRecList, nnkRecCase, nnkRecWhen,
  55. nnkRefTy, nnkPtrTy, nnkVarTy,
  56. nnkConstTy, nnkMutableTy,
  57. nnkDistinctTy,
  58. nnkProcTy,
  59. nnkIteratorTy, # iterator type
  60. nnkSharedTy, # 'shared T'
  61. nnkEnumTy,
  62. nnkEnumFieldDef,
  63. nnkArglist, nnkPattern
  64. nnkReturnToken,
  65. nnkClosure,
  66. nnkGotoState,
  67. nnkState,
  68. nnkBreakState,
  69. nnkFuncDef,
  70. nnkTupleConstr
  71. const
  72. nnkLiterals* = {nnkCharLit..nnkNilLit}
  73. nnkSomething* = {nnkStmtList, nnkStmtListExpr, nnkDiscardStmt, nnkVarSection, nnkLetSection,
  74. nnkConstSection, nnkPar, nnkAccQuoted, nnkAsgn, nnkDefer, nnkCurly, nnkBracket,
  75. nnkStaticStmt, nnkTableConstr, nnkExprColonExpr, nnkInfix, nnkPrefix,
  76. nnkRaiseStmt, nnkYieldStmt, nnkBracketExpr, nnkDotExpr, nnkCast, nnkBlockStmt,
  77. nnkExprEqExpr}
  78. type
  79. MyFictionalType = object
  80. a: int
  81. case n: NimNodeKind
  82. of nnkLiterals, nnkCommentStmt, nnkNone, nnkEmpty, nnkIdent, nnkSym,
  83. nnkType, nnkBindStmt, nnkMixinStmt, nnkTypeSection, nnkPragmaBlock,
  84. nnkPragmaExpr, nnkPragma, nnkBreakStmt, nnkCallStrLit, nnkPostfix,
  85. nnkOpenSymChoice:
  86. b: int
  87. of nnkCall, nnkCommand:
  88. c: int
  89. of nnkReturnStmt:
  90. d: int
  91. of nnkForStmt, nnkParForStmt, nnkWhileStmt, nnkProcDef, nnkMethodDef:
  92. e: int
  93. of nnkSomething, nnkRefTy, nnkPtrTy, nnkHiddenStdConv:
  94. f: int
  95. of nnkObjConstr:
  96. g: int
  97. of nnkIfStmt, nnkIfExpr, nnkWhenStmt:
  98. # if when and case statements are branching statements. So a
  99. # single function call is allowed to be in all of the braches and
  100. # the entire expression can still be considered as a forwarding
  101. # template.
  102. h: int
  103. of nnkCaseStmt:
  104. i: int
  105. of nnkTryStmt:
  106. j: int
  107. of nnkIdentDefs:
  108. k: int
  109. of nnkConstDef:
  110. l: int