twrong_setconstr.nim 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. discard """
  2. output: ""
  3. """
  4. # bug #2880
  5. type
  6. TMsgKind* = enum
  7. errUnknown, errIllFormedAstX, errInternal, errCannotOpenFile, errGenerated,
  8. errXCompilerDoesNotSupportCpp, errStringLiteralExpected,
  9. errIntLiteralExpected, errInvalidCharacterConstant,
  10. errClosingTripleQuoteExpected, errClosingQuoteExpected,
  11. errTabulatorsAreNotAllowed, errInvalidToken, errLineTooLong,
  12. errInvalidNumber, errInvalidNumberOctalCode, errNumberOutOfRange,
  13. errNnotAllowedInCharacter, errClosingBracketExpected, errMissingFinalQuote,
  14. errIdentifierExpected, errNewlineExpected, errInvalidModuleName,
  15. errOperatorExpected, errTokenExpected, errStringAfterIncludeExpected,
  16. errRecursiveDependencyX, errOnOrOffExpected, errNoneSpeedOrSizeExpected,
  17. errInvalidPragma, errUnknownPragma, errInvalidDirectiveX,
  18. errAtPopWithoutPush, errEmptyAsm, errInvalidIndentation,
  19. errExceptionExpected, errExceptionAlreadyHandled,
  20. errYieldNotAllowedHere, errYieldNotAllowedInTryStmt,
  21. errInvalidNumberOfYieldExpr, errCannotReturnExpr, errAttemptToRedefine,
  22. errStmtInvalidAfterReturn, errStmtExpected, errInvalidLabel,
  23. errInvalidCmdLineOption, errCmdLineArgExpected, errCmdLineNoArgExpected,
  24. errInvalidVarSubstitution, errUnknownVar, errUnknownCcompiler,
  25. errOnOrOffExpectedButXFound, errOnOffOrListExpectedButXFound,
  26. errNoneBoehmRefcExpectedButXFound,
  27. errNoneSpeedOrSizeExpectedButXFound, errGuiConsoleOrLibExpectedButXFound,
  28. errUnknownOS, errUnknownCPU, errGenOutExpectedButXFound,
  29. errArgsNeedRunOption, errInvalidMultipleAsgn, errColonOrEqualsExpected,
  30. errExprExpected, errUndeclaredIdentifier, errUseQualifier, errTypeExpected,
  31. errSystemNeeds, errExecutionOfProgramFailed, errNotOverloadable,
  32. errInvalidArgForX, errStmtHasNoEffect, errXExpectsTypeOrValue,
  33. errXExpectsArrayType, errIteratorCannotBeInstantiated, errExprXAmbiguous,
  34. errConstantDivisionByZero, errOrdinalTypeExpected,
  35. errOrdinalOrFloatTypeExpected, errOverOrUnderflow,
  36. errCannotEvalXBecauseIncompletelyDefined, errChrExpectsRange0_255,
  37. errDynlibRequiresExportc, errUndeclaredFieldX, errNilAccess,
  38. errIndexOutOfBounds, errIndexTypesDoNotMatch, errBracketsInvalidForType,
  39. errValueOutOfSetBounds, errFieldInitTwice, errFieldNotInit,
  40. errExprXCannotBeCalled, errExprHasNoType, errExprXHasNoType,
  41. errCastNotInSafeMode, errExprCannotBeCastedToX, errCommaOrParRiExpected,
  42. errCurlyLeOrParLeExpected, errSectionExpected, errRangeExpected,
  43. errMagicOnlyInSystem, errPowerOfTwoExpected,
  44. errStringMayNotBeEmpty, errCallConvExpected, errProcOnlyOneCallConv,
  45. errSymbolMustBeImported, errExprMustBeBool, errConstExprExpected,
  46. errDuplicateCaseLabel, errRangeIsEmpty, errSelectorMustBeOfCertainTypes,
  47. errSelectorMustBeOrdinal, errOrdXMustNotBeNegative, errLenXinvalid,
  48. errWrongNumberOfVariables, errExprCannotBeRaised, errBreakOnlyInLoop,
  49. errTypeXhasUnknownSize, errConstNeedsConstExpr, errConstNeedsValue,
  50. errResultCannotBeOpenArray, errSizeTooBig, errSetTooBig,
  51. errBaseTypeMustBeOrdinal, errInheritanceOnlyWithNonFinalObjects,
  52. errInheritanceOnlyWithEnums, errIllegalRecursionInTypeX,
  53. errCannotInstantiateX, errExprHasNoAddress, errXStackEscape,
  54. errVarForOutParamNeeded,
  55. errPureTypeMismatch, errTypeMismatch, errButExpected, errButExpectedX,
  56. errAmbiguousCallXYZ, errWrongNumberOfArguments,
  57. errXCannotBePassedToProcVar,
  58. errXCannotBeInParamDecl, errPragmaOnlyInHeaderOfProc, errImplOfXNotAllowed,
  59. errImplOfXexpected, errNoSymbolToBorrowFromFound, errDiscardValueX,
  60. errInvalidDiscard, errIllegalConvFromXtoY, errCannotBindXTwice,
  61. errInvalidOrderInArrayConstructor,
  62. errInvalidOrderInEnumX, errEnumXHasHoles, errExceptExpected, errInvalidTry,
  63. errOptionExpected, errXisNoLabel, errNotAllCasesCovered,
  64. errUnknownSubstitionVar, errComplexStmtRequiresInd, errXisNotCallable,
  65. errNoPragmasAllowedForX, errNoGenericParamsAllowedForX,
  66. errInvalidParamKindX, errDefaultArgumentInvalid, errNamedParamHasToBeIdent,
  67. errNoReturnTypeForX, errConvNeedsOneArg, errInvalidPragmaX,
  68. errXNotAllowedHere, errInvalidControlFlowX,
  69. errXisNoType, errCircumNeedsPointer, errInvalidExpression,
  70. errInvalidExpressionX, errEnumHasNoValueX, errNamedExprExpected,
  71. errNamedExprNotAllowed, errXExpectsOneTypeParam,
  72. errArrayExpectsTwoTypeParams, errInvalidVisibilityX, errInitHereNotAllowed,
  73. errXCannotBeAssignedTo, errIteratorNotAllowed, errXNeedsReturnType,
  74. errNoReturnTypeDeclared,
  75. errInvalidCommandX, errXOnlyAtModuleScope,
  76. errXNeedsParamObjectType,
  77. errTemplateInstantiationTooNested, errInstantiationFrom,
  78. errInvalidIndexValueForTuple, errCommandExpectsFilename,
  79. errMainModuleMustBeSpecified,
  80. errXExpected,
  81. errTIsNotAConcreteType,
  82. errInvalidSectionStart, errGridTableNotImplemented, errGeneralParseError,
  83. errNewSectionExpected, errWhitespaceExpected, errXisNoValidIndexFile,
  84. errCannotRenderX, errVarVarTypeNotAllowed, errInstantiateXExplicitly,
  85. errOnlyACallOpCanBeDelegator, errUsingNoSymbol,
  86. errMacroBodyDependsOnGenericTypes,
  87. errDestructorNotGenericEnough,
  88. errInlineIteratorsAsProcParams,
  89. errXExpectsTwoArguments,
  90. errXExpectsObjectTypes, errXcanNeverBeOfThisSubtype, errTooManyIterations,
  91. errCannotInterpretNodeX, errFieldXNotFound, errInvalidConversionFromTypeX,
  92. errAssertionFailed, errCannotGenerateCodeForX, errXRequiresOneArgument,
  93. errUnhandledExceptionX, errCyclicTree, errXisNoMacroOrTemplate,
  94. errXhasSideEffects, errIteratorExpected, errLetNeedsInit,
  95. errThreadvarCannotInit, errWrongSymbolX, errIllegalCaptureX,
  96. errXCannotBeClosure, errXMustBeCompileTime,
  97. errCannotInferTypeOfTheLiteral,
  98. errCannotInferReturnType,
  99. errGenericLambdaNotAllowed,
  100. errCompilerDoesntSupportTarget,
  101. errUser,
  102. warnCannotOpenFile,
  103. warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit,
  104. warnDeprecated, warnConfigDeprecated,
  105. warnSmallLshouldNotBeUsed, warnUnknownMagic, warnRedefinitionOfLabel,
  106. warnUnknownSubstitutionX, warnLanguageXNotSupported,
  107. warnFieldXNotSupported, warnCommentXIgnored,
  108. warnNilStatement, warnTypelessParam,
  109. warnDifferentHeaps, warnWriteToForeignHeap, warnUnsafeCode,
  110. warnEachIdentIsTuple, warnShadowIdent,
  111. warnProveInit, warnProveField, warnProveIndex, warnGcUnsafe, warnGcUnsafe2,
  112. warnUninit, warnGcMem, warnDestructor, warnLockLevel, warnResultShadowed,
  113. warnUser,
  114. hintSuccess, hintSuccessX,
  115. hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded,
  116. hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled,
  117. hintProcessing, hintCodeBegin, hintCodeEnd, hintConf, hintPath,
  118. hintConditionAlwaysTrue, hintName, hintPattern,
  119. hintExecuting, hintLinking, hintDependency,
  120. hintSource, hintStackTrace, hintGCStats,
  121. hintUser
  122. const
  123. warnMin = warnCannotOpenFile
  124. hintMax = high(TMsgKind)
  125. type
  126. TNoteKind = range[warnMin..hintMax] # "notes" are warnings or hints
  127. TNoteKinds = set[TNoteKind]
  128. const
  129. NotesVerbosityConst: array[0..0, TNoteKinds] = [
  130. {low(TNoteKind)..high(TNoteKind)} - {hintGCStats}]
  131. fuckyou = NotesVerbosityConst[0]
  132. var
  133. gNotesFromConst: TNoteKinds = NotesVerbosityConst[0]
  134. gNotesFromConst2: TNoteKinds = fuckyou
  135. if hintGCStats in gNotesFromConst:
  136. echo "hintGCStats in gNotesFromConst A"
  137. if hintGCStats in gNotesFromConst2:
  138. echo "hintGCStats in gNotesFromConst B"