diff options
-rw-r--r-- | compiler/jstypes.nim | 2 | ||||
-rw-r--r-- | compiler/main.nim | 6 | ||||
-rw-r--r-- | compiler/msgs.nim | 668 | ||||
-rw-r--r-- | compiler/parampatterns.nim | 41 | ||||
-rw-r--r-- | compiler/semexprs.nim | 7 | ||||
-rw-r--r-- | compiler/semparallel.nim | 7 | ||||
-rw-r--r-- | compiler/sigmatch.nim | 21 | ||||
-rw-r--r-- | compiler/vm.nim | 2 | ||||
-rw-r--r-- | doc/advopt.txt | 15 | ||||
-rw-r--r-- | doc/basicopt.txt | 1 | ||||
-rw-r--r-- | doc/manual/type_rel.txt | 169 | ||||
-rw-r--r-- | doc/manual/types.txt | 20 | ||||
-rw-r--r-- | lib/impure/osinfo_posix.nim | 87 | ||||
-rw-r--r-- | lib/impure/osinfo_win.nim | 421 | ||||
-rw-r--r-- | lib/pure/fenv.nim | 78 | ||||
-rw-r--r-- | lib/pure/logging.nim | 2 | ||||
-rw-r--r-- | lib/pure/md5.nim | 6 | ||||
-rw-r--r-- | lib/pure/redis.nim | 24 | ||||
-rw-r--r-- | lib/pure/times.nim | 22 | ||||
-rw-r--r-- | lib/system/sysio.nim | 2 | ||||
-rw-r--r-- | lib/wrappers/openssl.nim | 2 | ||||
-rw-r--r-- | tests/objects/tobjconstr.nim | 26 | ||||
-rw-r--r-- | todo.txt | 5 | ||||
-rw-r--r-- | web/news.txt | 410 |
24 files changed, 1025 insertions, 1019 deletions
diff --git a/compiler/jstypes.nim b/compiler/jstypes.nim index 8b032c3ce..1288c854d 100644 --- a/compiler/jstypes.nim +++ b/compiler/jstypes.nim @@ -123,7 +123,7 @@ proc genTypeInfo(p: PProc, typ: PType): PRope = case t.kind of tyDistinct: result = genTypeInfo(p, typ.sons[0]) - of tyPointer, tyProc, tyBool, tyChar, tyCString, tyString, tyInt..tyFloat128: + of tyPointer, tyProc, tyBool, tyChar, tyCString, tyString, tyInt..tyUInt64: var s = ropef( "var $1 = {size: 0,kind: $2,base: null,node: null,finalizer: null};$n", [result, toRope(ord(t.kind))]) diff --git a/compiler/main.nim b/compiler/main.nim index f7592a891..363327e40 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -58,7 +58,7 @@ proc commandCompileToC = registerPass(cgenPass) rodPass() #registerPass(cleanupPass()) - + compileProject() cgenWriteModules() if gCmd != cmdRun: @@ -363,7 +363,9 @@ proc mainCommand* = gVerbosity > 0): rawMessage(hintSuccessX, [$gLinesCompiled, formatFloat(epochTime() - gLastCmdTime, ffDecimal, 3), - formatSize(getTotalMem())]) + formatSize(getTotalMem()), + if condSyms.isDefined("release"): "Release Build" + else: "Debug Build"]) when PrintRopeCacheStats: echo "rope cache stats: " diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 4ea67989a..0f7921ddb 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -10,95 +10,95 @@ import options, strutils, os, tables, ropes, platform -type - TMsgKind* = enum - errUnknown, errIllFormedAstX, errInternal, errCannotOpenFile, errGenerated, - errXCompilerDoesNotSupportCpp, errStringLiteralExpected, - errIntLiteralExpected, errInvalidCharacterConstant, - errClosingTripleQuoteExpected, errClosingQuoteExpected, - errTabulatorsAreNotAllowed, errInvalidToken, errLineTooLong, - errInvalidNumber, errNumberOutOfRange, errNnotAllowedInCharacter, - errClosingBracketExpected, errMissingFinalQuote, errIdentifierExpected, +type + TMsgKind* = enum + errUnknown, errIllFormedAstX, errInternal, errCannotOpenFile, errGenerated, + errXCompilerDoesNotSupportCpp, errStringLiteralExpected, + errIntLiteralExpected, errInvalidCharacterConstant, + errClosingTripleQuoteExpected, errClosingQuoteExpected, + errTabulatorsAreNotAllowed, errInvalidToken, errLineTooLong, + errInvalidNumber, errNumberOutOfRange, errNnotAllowedInCharacter, + errClosingBracketExpected, errMissingFinalQuote, errIdentifierExpected, errNewlineExpected, errInvalidModuleName, - errOperatorExpected, errTokenExpected, errStringAfterIncludeExpected, - errRecursiveDependencyX, errOnOrOffExpected, errNoneSpeedOrSizeExpected, - errInvalidPragma, errUnknownPragma, errInvalidDirectiveX, - errAtPopWithoutPush, errEmptyAsm, errInvalidIndentation, - errExceptionExpected, errExceptionAlreadyHandled, - errYieldNotAllowedHere, errYieldNotAllowedInTryStmt, - errInvalidNumberOfYieldExpr, errCannotReturnExpr, errAttemptToRedefine, - errStmtInvalidAfterReturn, errStmtExpected, errInvalidLabel, - errInvalidCmdLineOption, errCmdLineArgExpected, errCmdLineNoArgExpected, - errInvalidVarSubstitution, errUnknownVar, errUnknownCcompiler, - errOnOrOffExpectedButXFound, errNoneBoehmRefcExpectedButXFound, - errNoneSpeedOrSizeExpectedButXFound, errGuiConsoleOrLibExpectedButXFound, - errUnknownOS, errUnknownCPU, errGenOutExpectedButXFound, - errArgsNeedRunOption, errInvalidMultipleAsgn, errColonOrEqualsExpected, - errExprExpected, errUndeclaredIdentifier, errUseQualifier, errTypeExpected, - errSystemNeeds, errExecutionOfProgramFailed, errNotOverloadable, - errInvalidArgForX, errStmtHasNoEffect, errXExpectsTypeOrValue, - errXExpectsArrayType, errIteratorCannotBeInstantiated, errExprXAmbiguous, - errConstantDivisionByZero, errOrdinalTypeExpected, - errOrdinalOrFloatTypeExpected, errOverOrUnderflow, - errCannotEvalXBecauseIncompletelyDefined, errChrExpectsRange0_255, - errDynlibRequiresExportc, errUndeclaredFieldX, errNilAccess, - errIndexOutOfBounds, errIndexTypesDoNotMatch, errBracketsInvalidForType, - errValueOutOfSetBounds, errFieldInitTwice, errFieldNotInit, - errExprXCannotBeCalled, errExprHasNoType, errExprXHasNoType, - errCastNotInSafeMode, errExprCannotBeCastedToX, errCommaOrParRiExpected, - errCurlyLeOrParLeExpected, errSectionExpected, errRangeExpected, - errMagicOnlyInSystem, errPowerOfTwoExpected, - errStringMayNotBeEmpty, errCallConvExpected, errProcOnlyOneCallConv, - errSymbolMustBeImported, errExprMustBeBool, errConstExprExpected, - errDuplicateCaseLabel, errRangeIsEmpty, errSelectorMustBeOfCertainTypes, - errSelectorMustBeOrdinal, errOrdXMustNotBeNegative, errLenXinvalid, - errWrongNumberOfVariables, errExprCannotBeRaised, errBreakOnlyInLoop, - errTypeXhasUnknownSize, errConstNeedsConstExpr, errConstNeedsValue, - errResultCannotBeOpenArray, errSizeTooBig, errSetTooBig, - errBaseTypeMustBeOrdinal, errInheritanceOnlyWithNonFinalObjects, - errInheritanceOnlyWithEnums, errIllegalRecursionInTypeX, + errOperatorExpected, errTokenExpected, errStringAfterIncludeExpected, + errRecursiveDependencyX, errOnOrOffExpected, errNoneSpeedOrSizeExpected, + errInvalidPragma, errUnknownPragma, errInvalidDirectiveX, + errAtPopWithoutPush, errEmptyAsm, errInvalidIndentation, + errExceptionExpected, errExceptionAlreadyHandled, + errYieldNotAllowedHere, errYieldNotAllowedInTryStmt, + errInvalidNumberOfYieldExpr, errCannotReturnExpr, errAttemptToRedefine, + errStmtInvalidAfterReturn, errStmtExpected, errInvalidLabel, + errInvalidCmdLineOption, errCmdLineArgExpected, errCmdLineNoArgExpected, + errInvalidVarSubstitution, errUnknownVar, errUnknownCcompiler, + errOnOrOffExpectedButXFound, errNoneBoehmRefcExpectedButXFound, + errNoneSpeedOrSizeExpectedButXFound, errGuiConsoleOrLibExpectedButXFound, + errUnknownOS, errUnknownCPU, errGenOutExpectedButXFound, + errArgsNeedRunOption, errInvalidMultipleAsgn, errColonOrEqualsExpected, + errExprExpected, errUndeclaredIdentifier, errUseQualifier, errTypeExpected, + errSystemNeeds, errExecutionOfProgramFailed, errNotOverloadable, + errInvalidArgForX, errStmtHasNoEffect, errXExpectsTypeOrValue, + errXExpectsArrayType, errIteratorCannotBeInstantiated, errExprXAmbiguous, + errConstantDivisionByZero, errOrdinalTypeExpected, + errOrdinalOrFloatTypeExpected, errOverOrUnderflow, + errCannotEvalXBecauseIncompletelyDefined, errChrExpectsRange0_255, + errDynlibRequiresExportc, errUndeclaredFieldX, errNilAccess, + errIndexOutOfBounds, errIndexTypesDoNotMatch, errBracketsInvalidForType, + errValueOutOfSetBounds, errFieldInitTwice, errFieldNotInit, + errExprXCannotBeCalled, errExprHasNoType, errExprXHasNoType, + errCastNotInSafeMode, errExprCannotBeCastedToX, errCommaOrParRiExpected, + errCurlyLeOrParLeExpected, errSectionExpected, errRangeExpected, + errMagicOnlyInSystem, errPowerOfTwoExpected, + errStringMayNotBeEmpty, errCallConvExpected, errProcOnlyOneCallConv, + errSymbolMustBeImported, errExprMustBeBool, errConstExprExpected, + errDuplicateCaseLabel, errRangeIsEmpty, errSelectorMustBeOfCertainTypes, + errSelectorMustBeOrdinal, errOrdXMustNotBeNegative, errLenXinvalid, + errWrongNumberOfVariables, errExprCannotBeRaised, errBreakOnlyInLoop, + errTypeXhasUnknownSize, errConstNeedsConstExpr, errConstNeedsValue, + errResultCannotBeOpenArray, errSizeTooBig, errSetTooBig, + errBaseTypeMustBeOrdinal, errInheritanceOnlyWithNonFinalObjects, + errInheritanceOnlyWithEnums, errIllegalRecursionInTypeX, errCannotInstantiateX, errExprHasNoAddress, errXStackEscape, - errVarForOutParamNeeded, - errPureTypeMismatch, errTypeMismatch, errButExpected, errButExpectedX, - errAmbiguousCallXYZ, errWrongNumberOfArguments, - errXCannotBePassedToProcVar, - errXCannotBeInParamDecl, errPragmaOnlyInHeaderOfProc, errImplOfXNotAllowed, - errImplOfXexpected, errNoSymbolToBorrowFromFound, errDiscardValueX, - errInvalidDiscard, errIllegalConvFromXtoY, errCannotBindXTwice, + errVarForOutParamNeeded, + errPureTypeMismatch, errTypeMismatch, errButExpected, errButExpectedX, + errAmbiguousCallXYZ, errWrongNumberOfArguments, + errXCannotBePassedToProcVar, + errXCannotBeInParamDecl, errPragmaOnlyInHeaderOfProc, errImplOfXNotAllowed, + errImplOfXexpected, errNoSymbolToBorrowFromFound, errDiscardValueX, + errInvalidDiscard, errIllegalConvFromXtoY, errCannotBindXTwice, errInvalidOrderInArrayConstructor, - errInvalidOrderInEnumX, errEnumXHasHoles, errExceptExpected, errInvalidTry, - errOptionExpected, errXisNoLabel, errNotAllCasesCovered, - errUnknownSubstitionVar, errComplexStmtRequiresInd, errXisNotCallable, - errNoPragmasAllowedForX, errNoGenericParamsAllowedForX, - errInvalidParamKindX, errDefaultArgumentInvalid, errNamedParamHasToBeIdent, - errNoReturnTypeForX, errConvNeedsOneArg, errInvalidPragmaX, + errInvalidOrderInEnumX, errEnumXHasHoles, errExceptExpected, errInvalidTry, + errOptionExpected, errXisNoLabel, errNotAllCasesCovered, + errUnknownSubstitionVar, errComplexStmtRequiresInd, errXisNotCallable, + errNoPragmasAllowedForX, errNoGenericParamsAllowedForX, + errInvalidParamKindX, errDefaultArgumentInvalid, errNamedParamHasToBeIdent, + errNoReturnTypeForX, errConvNeedsOneArg, errInvalidPragmaX, errXNotAllowedHere, errInvalidControlFlowX, - errXisNoType, errCircumNeedsPointer, errInvalidExpression, - errInvalidExpressionX, errEnumHasNoValueX, errNamedExprExpected, - errNamedExprNotAllowed, errXExpectsOneTypeParam, - errArrayExpectsTwoTypeParams, errInvalidVisibilityX, errInitHereNotAllowed, - errXCannotBeAssignedTo, errIteratorNotAllowed, errXNeedsReturnType, + errXisNoType, errCircumNeedsPointer, errInvalidExpression, + errInvalidExpressionX, errEnumHasNoValueX, errNamedExprExpected, + errNamedExprNotAllowed, errXExpectsOneTypeParam, + errArrayExpectsTwoTypeParams, errInvalidVisibilityX, errInitHereNotAllowed, + errXCannotBeAssignedTo, errIteratorNotAllowed, errXNeedsReturnType, errNoReturnTypeDeclared, - errInvalidCommandX, errXOnlyAtModuleScope, + errInvalidCommandX, errXOnlyAtModuleScope, errXNeedsParamObjectType, - errTemplateInstantiationTooNested, errInstantiationFrom, + errTemplateInstantiationTooNested, errInstantiationFrom, errInvalidIndexValueForTuple, errCommandExpectsFilename, errMainModuleMustBeSpecified, errXExpected, errTIsNotAConcreteType, - errInvalidSectionStart, errGridTableNotImplemented, errGeneralParseError, - errNewSectionExpected, errWhitespaceExpected, errXisNoValidIndexFile, + errInvalidSectionStart, errGridTableNotImplemented, errGeneralParseError, + errNewSectionExpected, errWhitespaceExpected, errXisNoValidIndexFile, errCannotRenderX, errVarVarTypeNotAllowed, errInstantiateXExplicitly, errOnlyACallOpCanBeDelegator, errUsingNoSymbol, errMacroBodyDependsOnGenericTypes, errDestructorNotGenericEnough, errInlineIteratorsAsProcParams, errXExpectsTwoArguments, - errXExpectsObjectTypes, errXcanNeverBeOfThisSubtype, errTooManyIterations, - errCannotInterpretNodeX, errFieldXNotFound, errInvalidConversionFromTypeX, - errAssertionFailed, errCannotGenerateCodeForX, errXRequiresOneArgument, - errUnhandledExceptionX, errCyclicTree, errXisNoMacroOrTemplate, + errXExpectsObjectTypes, errXcanNeverBeOfThisSubtype, errTooManyIterations, + errCannotInterpretNodeX, errFieldXNotFound, errInvalidConversionFromTypeX, + errAssertionFailed, errCannotGenerateCodeForX, errXRequiresOneArgument, + errUnhandledExceptionX, errCyclicTree, errXisNoMacroOrTemplate, errXhasSideEffects, errIteratorExpected, errLetNeedsInit, errThreadvarCannotInit, errWrongSymbolX, errIllegalCaptureX, errXCannotBeClosure, errXMustBeCompileTime, @@ -107,15 +107,15 @@ type errGenericLambdaNotAllowed, errCompilerDoesntSupportTarget, errUser, - warnCannotOpenFile, - warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit, + warnCannotOpenFile, + warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit, warnDeprecated, warnConfigDeprecated, - warnSmallLshouldNotBeUsed, warnUnknownMagic, warnRedefinitionOfLabel, + warnSmallLshouldNotBeUsed, warnUnknownMagic, warnRedefinitionOfLabel, warnUnknownSubstitutionX, warnLanguageXNotSupported, - warnFieldXNotSupported, warnCommentXIgnored, + warnFieldXNotSupported, warnCommentXIgnored, warnNilStatement, warnTypelessParam, warnDifferentHeaps, warnWriteToForeignHeap, warnUnsafeCode, - warnEachIdentIsTuple, warnShadowIdent, + warnEachIdentIsTuple, warnShadowIdent, warnProveInit, warnProveField, warnProveIndex, warnGcUnsafe, warnGcUnsafe2, warnUninit, warnGcMem, warnDestructor, warnLockLevel, warnResultShadowed, warnUser, @@ -126,205 +126,205 @@ type hintConditionAlwaysTrue, hintName, hintPattern, hintUser -const +const MsgKindToStr*: array[TMsgKind, string] = [ - errUnknown: "unknown error", + errUnknown: "unknown error", errIllFormedAstX: "illformed AST: $1", - errInternal: "internal error: $1", - errCannotOpenFile: "cannot open \'$1\'", - errGenerated: "$1", - errXCompilerDoesNotSupportCpp: "\'$1\' compiler does not support C++", - errStringLiteralExpected: "string literal expected", - errIntLiteralExpected: "integer literal expected", - errInvalidCharacterConstant: "invalid character constant", - errClosingTripleQuoteExpected: "closing \"\"\" expected, but end of file reached", - errClosingQuoteExpected: "closing \" expected", - errTabulatorsAreNotAllowed: "tabulators are not allowed", - errInvalidToken: "invalid token: $1", - errLineTooLong: "line too long", - errInvalidNumber: "$1 is not a valid number", - errNumberOutOfRange: "number $1 out of valid range", - errNnotAllowedInCharacter: "\\n not allowed in character literal", - errClosingBracketExpected: "closing ']' expected, but end of file reached", - errMissingFinalQuote: "missing final \' for character literal", - errIdentifierExpected: "identifier expected, but found \'$1\'", + errInternal: "internal error: $1", + errCannotOpenFile: "cannot open \'$1\'", + errGenerated: "$1", + errXCompilerDoesNotSupportCpp: "\'$1\' compiler does not support C++", + errStringLiteralExpected: "string literal expected", + errIntLiteralExpected: "integer literal expected", + errInvalidCharacterConstant: "invalid character constant", + errClosingTripleQuoteExpected: "closing \"\"\" expected, but end of file reached", + errClosingQuoteExpected: "closing \" expected", + errTabulatorsAreNotAllowed: "tabulators are not allowed", + errInvalidToken: "invalid token: $1", + errLineTooLong: "line too long", + errInvalidNumber: "$1 is not a valid number", + errNumberOutOfRange: "number $1 out of valid range", + errNnotAllowedInCharacter: "\\n not allowed in character literal", + errClosingBracketExpected: "closing ']' expected, but end of file reached", + errMissingFinalQuote: "missing final \' for character literal", + errIdentifierExpected: "identifier expected, but found \'$1\'", errNewlineExpected: "newline expected, but found \'$1\'", errInvalidModuleName: "invalid module name: '$1'", - errOperatorExpected: "operator expected, but found \'$1\'", - errTokenExpected: "\'$1\' expected", - errStringAfterIncludeExpected: "string after \'include\' expected", - errRecursiveDependencyX: "recursive dependency: \'$1\'", - errOnOrOffExpected: "\'on\' or \'off\' expected", - errNoneSpeedOrSizeExpected: "\'none\', \'speed\' or \'size\' expected", - errInvalidPragma: "invalid pragma", - errUnknownPragma: "unknown pragma: \'$1\'", - errInvalidDirectiveX: "invalid directive: \'$1\'", - errAtPopWithoutPush: "\'pop\' without a \'push\' pragma", - errEmptyAsm: "empty asm statement", - errInvalidIndentation: "invalid indentation", - errExceptionExpected: "exception expected", - errExceptionAlreadyHandled: "exception already handled", + errOperatorExpected: "operator expected, but found \'$1\'", + errTokenExpected: "\'$1\' expected", + errStringAfterIncludeExpected: "string after \'include\' expected", + errRecursiveDependencyX: "recursive dependency: \'$1\'", + errOnOrOffExpected: "\'on\' or \'off\' expected", + errNoneSpeedOrSizeExpected: "\'none\', \'speed\' or \'size\' expected", + errInvalidPragma: "invalid pragma", + errUnknownPragma: "unknown pragma: \'$1\'", + errInvalidDirectiveX: "invalid directive: \'$1\'", + errAtPopWithoutPush: "\'pop\' without a \'push\' pragma", + errEmptyAsm: "empty asm statement", + errInvalidIndentation: "invalid indentation", + errExceptionExpected: "exception expected", + errExceptionAlreadyHandled: "exception already handled", errYieldNotAllowedHere: "'yield' only allowed in an iterator", errYieldNotAllowedInTryStmt: "'yield' cannot be used within 'try' in a non-inlined iterator", - errInvalidNumberOfYieldExpr: "invalid number of \'yield\' expressions", - errCannotReturnExpr: "current routine cannot return an expression", - errAttemptToRedefine: "redefinition of \'$1\'", - errStmtInvalidAfterReturn: "statement not allowed after \'return\', \'break\', \'raise\' or \'continue'", - errStmtExpected: "statement expected", - errInvalidLabel: "\'$1\' is no label", - errInvalidCmdLineOption: "invalid command line option: \'$1\'", - errCmdLineArgExpected: "argument for command line option expected: \'$1\'", - errCmdLineNoArgExpected: "invalid argument for command line option: \'$1\'", - errInvalidVarSubstitution: "invalid variable substitution in \'$1\'", - errUnknownVar: "unknown variable: \'$1\'", - errUnknownCcompiler: "unknown C compiler: \'$1\'", - errOnOrOffExpectedButXFound: "\'on\' or \'off\' expected, but \'$1\' found", - errNoneBoehmRefcExpectedButXFound: "'none', 'boehm' or 'refc' expected, but '$1' found", - errNoneSpeedOrSizeExpectedButXFound: "'none', 'speed' or 'size' expected, but '$1' found", - errGuiConsoleOrLibExpectedButXFound: "'gui', 'console' or 'lib' expected, but '$1' found", - errUnknownOS: "unknown OS: '$1'", - errUnknownCPU: "unknown CPU: '$1'", - errGenOutExpectedButXFound: "'c', 'c++' or 'yaml' expected, but '$1' found", - errArgsNeedRunOption: "arguments can only be given if the '--run' option is selected", - errInvalidMultipleAsgn: "multiple assignment is not allowed", - errColonOrEqualsExpected: "\':\' or \'=\' expected, but found \'$1\'", - errExprExpected: "expression expected, but found \'$1\'", - errUndeclaredIdentifier: "undeclared identifier: \'$1\'", - errUseQualifier: "ambiguous identifier: \'$1\' -- use a qualifier", - errTypeExpected: "type expected", - errSystemNeeds: "system module needs \'$1\'", - errExecutionOfProgramFailed: "execution of an external program failed", - errNotOverloadable: "overloaded \'$1\' leads to ambiguous calls", - errInvalidArgForX: "invalid argument for \'$1\'", - errStmtHasNoEffect: "statement has no effect", - errXExpectsTypeOrValue: "\'$1\' expects a type or value", - errXExpectsArrayType: "\'$1\' expects an array type", - errIteratorCannotBeInstantiated: "'$1' cannot be instantiated because its body has not been compiled yet", - errExprXAmbiguous: "expression '$1' ambiguous in this context", - errConstantDivisionByZero: "division by zero", - errOrdinalTypeExpected: "ordinal type expected", - errOrdinalOrFloatTypeExpected: "ordinal or float type expected", - errOverOrUnderflow: "over- or underflow", - errCannotEvalXBecauseIncompletelyDefined: "cannot evalutate '$1' because type is not defined completely", - errChrExpectsRange0_255: "\'chr\' expects an int in the range 0..255", - errDynlibRequiresExportc: "\'dynlib\' requires \'exportc\'", - errUndeclaredFieldX: "undeclared field: \'$1\'", + errInvalidNumberOfYieldExpr: "invalid number of \'yield\' expressions", + errCannotReturnExpr: "current routine cannot return an expression", + errAttemptToRedefine: "redefinition of \'$1\'", + errStmtInvalidAfterReturn: "statement not allowed after \'return\', \'break\', \'raise\' or \'continue'", + errStmtExpected: "statement expected", + errInvalidLabel: "\'$1\' is no label", + errInvalidCmdLineOption: "invalid command line option: \'$1\'", + errCmdLineArgExpected: "argument for command line option expected: \'$1\'", + errCmdLineNoArgExpected: "invalid argument for command line option: \'$1\'", + errInvalidVarSubstitution: "invalid variable substitution in \'$1\'", + errUnknownVar: "unknown variable: \'$1\'", + errUnknownCcompiler: "unknown C compiler: \'$1\'", + errOnOrOffExpectedButXFound: "\'on\' or \'off\' expected, but \'$1\' found", + errNoneBoehmRefcExpectedButXFound: "'none', 'boehm' or 'refc' expected, but '$1' found", + errNoneSpeedOrSizeExpectedButXFound: "'none', 'speed' or 'size' expected, but '$1' found", + errGuiConsoleOrLibExpectedButXFound: "'gui', 'console' or 'lib' expected, but '$1' found", + errUnknownOS: "unknown OS: '$1'", + errUnknownCPU: "unknown CPU: '$1'", + errGenOutExpectedButXFound: "'c', 'c++' or 'yaml' expected, but '$1' found", + errArgsNeedRunOption: "arguments can only be given if the '--run' option is selected", + errInvalidMultipleAsgn: "multiple assignment is not allowed", + errColonOrEqualsExpected: "\':\' or \'=\' expected, but found \'$1\'", + errExprExpected: "expression expected, but found \'$1\'", + errUndeclaredIdentifier: "undeclared identifier: \'$1\'", + errUseQualifier: "ambiguous identifier: \'$1\' -- use a qualifier", + errTypeExpected: "type expected", + errSystemNeeds: "system module needs \'$1\'", + errExecutionOfProgramFailed: "execution of an external program failed", + errNotOverloadable: "overloaded \'$1\' leads to ambiguous calls", + errInvalidArgForX: "invalid argument for \'$1\'", + errStmtHasNoEffect: "statement has no effect", + errXExpectsTypeOrValue: "\'$1\' expects a type or value", + errXExpectsArrayType: "\'$1\' expects an array type", + errIteratorCannotBeInstantiated: "'$1' cannot be instantiated because its body has not been compiled yet", + errExprXAmbiguous: "expression '$1' ambiguous in this context", + errConstantDivisionByZero: "division by zero", + errOrdinalTypeExpected: "ordinal type expected", + errOrdinalOrFloatTypeExpected: "ordinal or float type expected", + errOverOrUnderflow: "over- or underflow", + errCannotEvalXBecauseIncompletelyDefined: "cannot evalutate '$1' because type is not defined completely", + errChrExpectsRange0_255: "\'chr\' expects an int in the range 0..255", + errDynlibRequiresExportc: "\'dynlib\' requires \'exportc\'", + errUndeclaredFieldX: "undeclared field: \'$1\'", errNilAccess: "attempt to access a nil address", - errIndexOutOfBounds: "index out of bounds", - errIndexTypesDoNotMatch: "index types do not match", - errBracketsInvalidForType: "\'[]\' operator invalid for this type", - errValueOutOfSetBounds: "value out of set bounds", - errFieldInitTwice: "field initialized twice: \'$1\'", - errFieldNotInit: "field \'$1\' not initialized", - errExprXCannotBeCalled: "expression \'$1\' cannot be called", - errExprHasNoType: "expression has no type", - errExprXHasNoType: "expression \'$1\' has no type (or is ambiguous)", + errIndexOutOfBounds: "index out of bounds", + errIndexTypesDoNotMatch: "index types do not match", + errBracketsInvalidForType: "\'[]\' operator invalid for this type", + errValueOutOfSetBounds: "value out of set bounds", + errFieldInitTwice: "field initialized twice: \'$1\'", + errFieldNotInit: "field \'$1\' not initialized", + errExprXCannotBeCalled: "expression \'$1\' cannot be called", + errExprHasNoType: "expression has no type", + errExprXHasNoType: "expression \'$1\' has no type (or is ambiguous)", errCastNotInSafeMode: "\'cast\' not allowed in safe mode", - errExprCannotBeCastedToX: "expression cannot be casted to $1", - errCommaOrParRiExpected: "',' or ')' expected", - errCurlyLeOrParLeExpected: "\'{\' or \'(\' expected", - errSectionExpected: "section (\'type\', \'proc\', etc.) expected", - errRangeExpected: "range expected", - errMagicOnlyInSystem: "\'magic\' only allowed in system module", + errExprCannotBeCastedToX: "expression cannot be casted to $1", + errCommaOrParRiExpected: "',' or ')' expected", + errCurlyLeOrParLeExpected: "\'{\' or \'(\' expected", + errSectionExpected: "section (\'type\', \'proc\', etc.) expected", + errRangeExpected: "range expected", + errMagicOnlyInSystem: "\'magic\' only allowed in system module", errPowerOfTwoExpected: "power of two expected", - errStringMayNotBeEmpty: "string literal may not be empty", - errCallConvExpected: "calling convention expected", - errProcOnlyOneCallConv: "a proc can only have one calling convention", - errSymbolMustBeImported: "symbol must be imported if 'lib' pragma is used", - errExprMustBeBool: "expression must be of type 'bool'", - errConstExprExpected: "constant expression expected", - errDuplicateCaseLabel: "duplicate case label", - errRangeIsEmpty: "range is empty", - errSelectorMustBeOfCertainTypes: "selector must be of an ordinal type, float or string", - errSelectorMustBeOrdinal: "selector must be of an ordinal type", - errOrdXMustNotBeNegative: "ord($1) must not be negative", + errStringMayNotBeEmpty: "string literal may not be empty", + errCallConvExpected: "calling convention expected", + errProcOnlyOneCallConv: "a proc can only have one calling convention", + errSymbolMustBeImported: "symbol must be imported if 'lib' pragma is used", + errExprMustBeBool: "expression must be of type 'bool'", + errConstExprExpected: "constant expression expected", + errDuplicateCaseLabel: "duplicate case label", + errRangeIsEmpty: "range is empty", + errSelectorMustBeOfCertainTypes: "selector must be of an ordinal type, float or string", + errSelectorMustBeOrdinal: "selector must be of an ordinal type", + errOrdXMustNotBeNegative: "ord($1) must not be negative", errLenXinvalid: "len($1) must be less than 32768", - errWrongNumberOfVariables: "wrong number of variables", - errExprCannotBeRaised: "only a 'ref object' can be raised", - errBreakOnlyInLoop: "'break' only allowed in loop construct", - errTypeXhasUnknownSize: "type \'$1\' has unknown size", - errConstNeedsConstExpr: "a constant can only be initialized with a constant expression", - errConstNeedsValue: "a constant needs a value", - errResultCannotBeOpenArray: "the result type cannot be on open array", - errSizeTooBig: "computing the type\'s size produced an overflow", - errSetTooBig: "set is too large", - errBaseTypeMustBeOrdinal: "base type of a set must be an ordinal", - errInheritanceOnlyWithNonFinalObjects: "inheritance only works with non-final objects", + errWrongNumberOfVariables: "wrong number of variables", + errExprCannotBeRaised: "only a 'ref object' can be raised", + errBreakOnlyInLoop: "'break' only allowed in loop construct", + errTypeXhasUnknownSize: "type \'$1\' has unknown size", + errConstNeedsConstExpr: "a constant can only be initialized with a constant expression", + errConstNeedsValue: "a constant needs a value", + errResultCannotBeOpenArray: "the result type cannot be on open array", + errSizeTooBig: "computing the type\'s size produced an overflow", + errSetTooBig: "set is too large", + errBaseTypeMustBeOrdinal: "base type of a set must be an ordinal", + errInheritanceOnlyWithNonFinalObjects: "inheritance only works with non-final objects", errInheritanceOnlyWithEnums: "inheritance only works with an enum", - errIllegalRecursionInTypeX: "illegal recursion in type \'$1\'", - errCannotInstantiateX: "cannot instantiate: \'$1\'", - errExprHasNoAddress: "expression has no address", + errIllegalRecursionInTypeX: "illegal recursion in type \'$1\'", + errCannotInstantiateX: "cannot instantiate: \'$1\'", + errExprHasNoAddress: "expression has no address", errXStackEscape: "address of '$1' may not escape its stack frame", errVarForOutParamNeeded: "for a \'var\' type a variable needs to be passed", - errPureTypeMismatch: "type mismatch", - errTypeMismatch: "type mismatch: got (", + errPureTypeMismatch: "type mismatch", + errTypeMismatch: "type mismatch: got (", errButExpected: "but expected one of: ", - errButExpectedX: "but expected \'$1\'", - errAmbiguousCallXYZ: "ambiguous call; both $1 and $2 match for: $3", - errWrongNumberOfArguments: "wrong number of arguments", - errXCannotBePassedToProcVar: "\'$1\' cannot be passed to a procvar", - errXCannotBeInParamDecl: "$1 cannot be declared in parameter declaration", - errPragmaOnlyInHeaderOfProc: "pragmas are only allowed in the header of a proc", - errImplOfXNotAllowed: "implementation of \'$1\' is not allowed", - errImplOfXexpected: "implementation of \'$1\' expected", - errNoSymbolToBorrowFromFound: "no symbol to borrow from found", - errDiscardValueX: "value of type '$1' has to be discarded", - errInvalidDiscard: "statement returns no value that can be discarded", + errButExpectedX: "but expected \'$1\'", + errAmbiguousCallXYZ: "ambiguous call; both $1 and $2 match for: $3", + errWrongNumberOfArguments: "wrong number of arguments", + errXCannotBePassedToProcVar: "\'$1\' cannot be passed to a procvar", + errXCannotBeInParamDecl: "$1 cannot be declared in parameter declaration", + errPragmaOnlyInHeaderOfProc: "pragmas are only allowed in the header of a proc", + errImplOfXNotAllowed: "implementation of \'$1\' is not allowed", + errImplOfXexpected: "implementation of \'$1\' expected", + errNoSymbolToBorrowFromFound: "no symbol to borrow from found", + errDiscardValueX: "value of type '$1' has to be discarded", + errInvalidDiscard: "statement returns no value that can be discarded", errIllegalConvFromXtoY: "conversion from $1 to $2 is invalid", - errCannotBindXTwice: "cannot bind parameter \'$1\' twice", + errCannotBindXTwice: "cannot bind parameter \'$1\' twice", errInvalidOrderInArrayConstructor: "invalid order in array constructor", - errInvalidOrderInEnumX: "invalid order in enum \'$1\'", - errEnumXHasHoles: "enum \'$1\' has holes", - errExceptExpected: "\'except\' or \'finally\' expected", - errInvalidTry: "after catch all \'except\' or \'finally\' no section may follow", + errInvalidOrderInEnumX: "invalid order in enum \'$1\'", + errEnumXHasHoles: "enum \'$1\' has holes", + errExceptExpected: "\'except\' or \'finally\' expected", + errInvalidTry: "after catch all \'except\' or \'finally\' no section may follow", errOptionExpected: "option expected, but found \'$1\'", - errXisNoLabel: "\'$1\' is not a label", - errNotAllCasesCovered: "not all cases are covered", - errUnknownSubstitionVar: "unknown substitution variable: \'$1\'", + errXisNoLabel: "\'$1\' is not a label", + errNotAllCasesCovered: "not all cases are covered", + errUnknownSubstitionVar: "unknown substitution variable: \'$1\'", errComplexStmtRequiresInd: "complex statement requires indentation", - errXisNotCallable: "\'$1\' is not callable", - errNoPragmasAllowedForX: "no pragmas allowed for $1", - errNoGenericParamsAllowedForX: "no generic parameters allowed for $1", - errInvalidParamKindX: "invalid param kind: \'$1\'", - errDefaultArgumentInvalid: "default argument invalid", - errNamedParamHasToBeIdent: "named parameter has to be an identifier", - errNoReturnTypeForX: "no return type allowed for $1", - errConvNeedsOneArg: "a type conversion needs exactly one argument", - errInvalidPragmaX: "invalid pragma: $1", + errXisNotCallable: "\'$1\' is not callable", + errNoPragmasAllowedForX: "no pragmas allowed for $1", + errNoGenericParamsAllowedForX: "no generic parameters allowed for $1", + errInvalidParamKindX: "invalid param kind: \'$1\'", + errDefaultArgumentInvalid: "default argument invalid", + errNamedParamHasToBeIdent: "named parameter has to be an identifier", + errNoReturnTypeForX: "no return type allowed for $1", + errConvNeedsOneArg: "a type conversion needs exactly one argument", + errInvalidPragmaX: "invalid pragma: $1", errXNotAllowedHere: "$1 not allowed here", errInvalidControlFlowX: "invalid control flow: $1", errXisNoType: "invalid type: \'$1\'", - errCircumNeedsPointer: "'[]' needs a pointer or reference type", + errCircumNeedsPointer: "'[]' needs a pointer or reference type", errInvalidExpression: "invalid expression", - errInvalidExpressionX: "invalid expression: \'$1\'", + errInvalidExpressionX: "invalid expression: \'$1\'", errEnumHasNoValueX: "enum has no value \'$1\'", - errNamedExprExpected: "named expression expected", - errNamedExprNotAllowed: "named expression not allowed here", - errXExpectsOneTypeParam: "\'$1\' expects one type parameter", - errArrayExpectsTwoTypeParams: "array expects two type parameters", - errInvalidVisibilityX: "invalid visibility: \'$1\'", - errInitHereNotAllowed: "initialization not allowed here", - errXCannotBeAssignedTo: "\'$1\' cannot be assigned to", - errIteratorNotAllowed: "iterators can only be defined at the module\'s top level", + errNamedExprExpected: "named expression expected", + errNamedExprNotAllowed: "named expression not allowed here", + errXExpectsOneTypeParam: "\'$1\' expects one type parameter", + errArrayExpectsTwoTypeParams: "array expects two type parameters", + errInvalidVisibilityX: "invalid visibility: \'$1\'", + errInitHereNotAllowed: "initialization not allowed here", + errXCannotBeAssignedTo: "\'$1\' cannot be assigned to", + errIteratorNotAllowed: "iterators can only be defined at the module\'s top level", errXNeedsReturnType: "$1 needs a return type", errNoReturnTypeDeclared: "no return type declared", - errInvalidCommandX: "invalid command: \'$1\'", - errXOnlyAtModuleScope: "\'$1\' is only allowed at top level", + errInvalidCommandX: "invalid command: \'$1\'", + errXOnlyAtModuleScope: "\'$1\' is only allowed at top level", errXNeedsParamObjectType: "'$1' needs a parameter that has an object type", errTemplateInstantiationTooNested: "template/macro instantiation too nested", - errInstantiationFrom: "template/generic instantiation from here", - errInvalidIndexValueForTuple: "invalid index value for tuple subscript", + errInstantiationFrom: "template/generic instantiation from here", + errInvalidIndexValueForTuple: "invalid index value for tuple subscript", errCommandExpectsFilename: "command expects a filename argument", errMainModuleMustBeSpecified: "please, specify a main module in the project configuration file", - errXExpected: "\'$1\' expected", + errXExpected: "\'$1\' expected", errTIsNotAConcreteType: "\'$1\' is not a concrete type.", errInvalidSectionStart: "invalid section start", - errGridTableNotImplemented: "grid table is not implemented", + errGridTableNotImplemented: "grid table is not implemented", errGeneralParseError: "general parse error", - errNewSectionExpected: "new section expected", + errNewSectionExpected: "new section expected", errWhitespaceExpected: "whitespace expected, got \'$1\'", - errXisNoValidIndexFile: "\'$1\' is no valid index file", - errCannotRenderX: "cannot render reStructuredText element \'$1\'", + errXisNoValidIndexFile: "\'$1\' is no valid index file", + errCannotRenderX: "cannot render reStructuredText element \'$1\'", errVarVarTypeNotAllowed: "type \'var var\' is not allowed", errInstantiateXExplicitly: "instantiate '$1' explicitly", errOnlyACallOpCanBeDelegator: "only a call operator can be a delegator", @@ -335,24 +335,24 @@ const "A destructor must be associated will all instantiations of a generic type", errInlineIteratorsAsProcParams: "inline iterators can be used as parameters only for " & "templates, macros and other inline iterators", - errXExpectsTwoArguments: "\'$1\' expects two arguments", + errXExpectsTwoArguments: "\'$1\' expects two arguments", errXExpectsObjectTypes: "\'$1\' expects object types", - errXcanNeverBeOfThisSubtype: "\'$1\' can never be of this subtype", - errTooManyIterations: "interpretation requires too many iterations", - errCannotInterpretNodeX: "cannot evaluate \'$1\'", - errFieldXNotFound: "field \'$1\' cannot be found", + errXcanNeverBeOfThisSubtype: "\'$1\' can never be of this subtype", + errTooManyIterations: "interpretation requires too many iterations", + errCannotInterpretNodeX: "cannot evaluate \'$1\'", + errFieldXNotFound: "field \'$1\' cannot be found", errInvalidConversionFromTypeX: "invalid conversion from type \'$1\'", - errAssertionFailed: "assertion failed", - errCannotGenerateCodeForX: "cannot generate code for \'$1\'", - errXRequiresOneArgument: "$1 requires one parameter", - errUnhandledExceptionX: "unhandled exception: $1", - errCyclicTree: "macro returned a cyclic abstract syntax tree", + errAssertionFailed: "assertion failed", + errCannotGenerateCodeForX: "cannot generate code for \'$1\'", + errXRequiresOneArgument: "$1 requires one parameter", + errUnhandledExceptionX: "unhandled exception: $1", + errCyclicTree: "macro returned a cyclic abstract syntax tree", errXisNoMacroOrTemplate: "\'$1\' is no macro or template", - errXhasSideEffects: "\'$1\' can have side effects", + errXhasSideEffects: "\'$1\' can have side effects", errIteratorExpected: "iterator within for loop context expected", errLetNeedsInit: "'let' symbol requires an initialization", errThreadvarCannotInit: "a thread var cannot be initialized explicitly", - errWrongSymbolX: "usage of \'$1\' is a user-defined error", + errWrongSymbolX: "usage of \'$1\' is a user-defined error", errIllegalCaptureX: "illegal capture '$1'", errXCannotBeClosure: "'$1' cannot have 'closure' calling convention", errXMustBeCompileTime: "'$1' can only be used in compile-time context", @@ -362,21 +362,21 @@ const "it is used as an operand to another routine and the types " & "of the generic paramers can be inferred from the expected signature.", errCompilerDoesntSupportTarget: "The current compiler \'$1\' doesn't support the requested compilation target", - errUser: "$1", + errUser: "$1", warnCannotOpenFile: "cannot open \'$1\' [CannotOpenFile]", - warnOctalEscape: "octal escape sequences do not exist; leading zero is ignored [OctalEscape]", - warnXIsNeverRead: "\'$1\' is never read [XIsNeverRead]", - warnXmightNotBeenInit: "\'$1\' might not have been initialized [XmightNotBeenInit]", - warnDeprecated: "$1 is deprecated [Deprecated]", + warnOctalEscape: "octal escape sequences do not exist; leading zero is ignored [OctalEscape]", + warnXIsNeverRead: "\'$1\' is never read [XIsNeverRead]", + warnXmightNotBeenInit: "\'$1\' might not have been initialized [XmightNotBeenInit]", + warnDeprecated: "$1 is deprecated [Deprecated]", warnConfigDeprecated: "config file '$1' is deprecated [ConfigDeprecated]", - warnSmallLshouldNotBeUsed: "\'l\' should not be used as an identifier; may look like \'1\' (one) [SmallLshouldNotBeUsed]", - warnUnknownMagic: "unknown magic \'$1\' might crash the compiler [UnknownMagic]", - warnRedefinitionOfLabel: "redefinition of label \'$1\' [RedefinitionOfLabel]", - warnUnknownSubstitutionX: "unknown substitution \'$1\' [UnknownSubstitutionX]", - warnLanguageXNotSupported: "language \'$1\' not supported [LanguageXNotSupported]", - warnFieldXNotSupported: "field \'$1\' not supported [FieldXNotSupported]", - warnCommentXIgnored: "comment \'$1\' ignored [CommentXIgnored]", - warnNilStatement: "'nil' statement is deprecated; use an empty 'discard' statement instead [NilStmt]", + warnSmallLshouldNotBeUsed: "\'l\' should not be used as an identifier; may look like \'1\' (one) [SmallLshouldNotBeUsed]", + warnUnknownMagic: "unknown magic \'$1\' might crash the compiler [UnknownMagic]", + warnRedefinitionOfLabel: "redefinition of label \'$1\' [RedefinitionOfLabel]", + warnUnknownSubstitutionX: "unknown substitution \'$1\' [UnknownSubstitutionX]", + warnLanguageXNotSupported: "language \'$1\' not supported [LanguageXNotSupported]", + warnFieldXNotSupported: "field \'$1\' not supported [FieldXNotSupported]", + warnCommentXIgnored: "comment \'$1\' ignored [CommentXIgnored]", + warnNilStatement: "'nil' statement is deprecated; use an empty 'discard' statement instead [NilStmt]", warnTypelessParam: "'$1' has no type. Typeless parameters are deprecated; only allowed for 'template' [TypelessParam]", warnDifferentHeaps: "possible inconsistency of thread local heaps [DifferentHeaps]", warnWriteToForeignHeap: "write to foreign heap [WriteToForeignHeap]", @@ -393,19 +393,19 @@ const warnDestructor: "usage of a type with a destructor in a non destructible context. This will become a compile time error in the future. [Destructor]", warnLockLevel: "$1 [LockLevel]", warnResultShadowed: "Special variable 'result' is shadowed. [ResultShadowed]", - warnUser: "$1 [User]", - hintSuccess: "operation successful [Success]", - hintSuccessX: "operation successful ($# lines compiled; $# sec total; $#) [SuccessX]", - hintLineTooLong: "line too long [LineTooLong]", - hintXDeclaredButNotUsed: "\'$1\' is declared but not used [XDeclaredButNotUsed]", - hintConvToBaseNotNeeded: "conversion to base object is not needed [ConvToBaseNotNeeded]", - hintConvFromXtoItselfNotNeeded: "conversion from $1 to itself is pointless [ConvFromXtoItselfNotNeeded]", - hintExprAlwaysX: "expression evaluates always to \'$1\' [ExprAlwaysX]", + warnUser: "$1 [User]", + hintSuccess: "operation successful [Success]", + hintSuccessX: "operation successful ($# lines compiled; $# sec total; $#; $#) [SuccessX]", + hintLineTooLong: "line too long [LineTooLong]", + hintXDeclaredButNotUsed: "\'$1\' is declared but not used [XDeclaredButNotUsed]", + hintConvToBaseNotNeeded: "conversion to base object is not needed [ConvToBaseNotNeeded]", + hintConvFromXtoItselfNotNeeded: "conversion from $1 to itself is pointless [ConvFromXtoItselfNotNeeded]", + hintExprAlwaysX: "expression evaluates always to \'$1\' [ExprAlwaysX]", hintQuitCalled: "quit() called [QuitCalled]", - hintProcessing: "$1 [Processing]", + hintProcessing: "$1 [Processing]", hintCodeBegin: "generated code listing: [CodeBegin]", - hintCodeEnd: "end of listing [CodeEnd]", - hintConf: "used config file \'$1\' [Conf]", + hintCodeEnd: "end of listing [CodeEnd]", + hintConf: "used config file \'$1\' [Conf]", hintPath: "added path: '$1' [Path]", hintConditionAlwaysTrue: "condition is always true: '$1' [CondTrue]", hintName: "name should be: '$1' [Name]", @@ -413,25 +413,25 @@ const hintUser: "$1 [User]"] const - WarningsToStr*: array[0..30, string] = ["CannotOpenFile", "OctalEscape", + WarningsToStr*: array[0..30, string] = ["CannotOpenFile", "OctalEscape", "XIsNeverRead", "XmightNotBeenInit", "Deprecated", "ConfigDeprecated", - "SmallLshouldNotBeUsed", "UnknownMagic", + "SmallLshouldNotBeUsed", "UnknownMagic", "RedefinitionOfLabel", "UnknownSubstitutionX", "LanguageXNotSupported", "FieldXNotSupported", "CommentXIgnored", "NilStmt", "TypelessParam", "DifferentHeaps", "WriteToForeignHeap", - "UnsafeCode", "EachIdentIsTuple", "ShadowIdent", + "UnsafeCode", "EachIdentIsTuple", "ShadowIdent", "ProveInit", "ProveField", "ProveIndex", "GcUnsafe", "GcUnsafe2", "Uninit", "GcMem", "Destructor", "LockLevel", "ResultShadowed", "User"] - HintsToStr*: array[0..16, string] = ["Success", "SuccessX", "LineTooLong", - "XDeclaredButNotUsed", "ConvToBaseNotNeeded", "ConvFromXtoItselfNotNeeded", - "ExprAlwaysX", "QuitCalled", "Processing", "CodeBegin", "CodeEnd", "Conf", + HintsToStr*: array[0..16, string] = ["Success", "SuccessX", "LineTooLong", + "XDeclaredButNotUsed", "ConvToBaseNotNeeded", "ConvFromXtoItselfNotNeeded", + "ExprAlwaysX", "QuitCalled", "Processing", "CodeBegin", "CodeEnd", "Conf", "Path", "CondTrue", "Name", "Pattern", "User"] -const +const fatalMin* = errUnknown fatalMax* = errInternal errMin* = errUnknown @@ -440,18 +440,18 @@ const warnMax* = pred(hintSuccess) hintMin* = hintSuccess hintMax* = high(TMsgKind) - -type + +type TNoteKind* = range[warnMin..hintMax] # "notes" are warnings or hints TNoteKinds* = set[TNoteKind] - TFileInfo* = object + TFileInfo* = object fullPath: string # This is a canonical full filesystem path projPath*: string # This is relative to the project's root shortName*: string # short name of the module quotedName*: PRope # cached quoted short name for codegen # purposes - + lines*: seq[PRope] # the source code of the module # used for better error messages and # embedding the original source in the @@ -462,13 +462,13 @@ type TLineInfo* = object # This is designed to be as small as possible, # because it is used - # in syntax nodes. We save space here by using + # in syntax nodes. We save space here by using # two int16 and an int32. - # On 64 bit and on 32 bit systems this is + # On 64 bit and on 32 bit systems this is # only 8 bytes. line*, col*: int16 fileIndex*: int32 - + TErrorOutput* = enum eStdOut eStdErr @@ -487,7 +487,7 @@ var fileInfos*: seq[TFileInfo] = @[] systemFileIdx*: int32 -proc toCChar*(c: char): string = +proc toCChar*(c: char): string = case c of '\0'..'\x1F', '\x80'..'\xFF': result = '\\' & toOctal(c) of '\'', '\"', '\\': result = '\\' & c @@ -497,7 +497,7 @@ proc makeCString*(s: string): PRope = # BUGFIX: We have to split long strings into many ropes. Otherwise # this could trigger an internalError(). See the ropes module for # further information. - const + const MaxLineLength = 64 result = nil var res = "\"" @@ -571,7 +571,7 @@ proc raiseRecoverableError*(msg: string) {.noinline, noreturn.} = proc sourceLine*(i: TLineInfo): PRope var - gNotes*: TNoteKinds = {low(TNoteKind)..high(TNoteKind)} - + gNotes*: TNoteKinds = {low(TNoteKind)..high(TNoteKind)} - {warnShadowIdent, warnUninit, warnProveField, warnProveIndex, warnGcUnsafe} gErrorCounter*: int = 0 # counts the number of errors @@ -584,7 +584,7 @@ proc unknownLineInfo*(): TLineInfo = result.col = int16(-1) result.fileIndex = -1 -var +var msgContext: seq[TLineInfo] = @[] lastError = unknownLineInfo() bufferedMsgs*: seq[string] @@ -599,7 +599,7 @@ proc suggestWriteln*(s: string) = if eStdOut in errorOutputs: if isNil(writelnHook): writeln(stdout, s) else: writelnHook(s) - + if eInMemory in errorOutputs: bufferedMsgs.safeAdd(s) @@ -623,10 +623,10 @@ const proc getInfoContextLen*(): int = return msgContext.len proc setInfoContextLen*(L: int) = setLen(msgContext, L) -proc pushInfoContext*(info: TLineInfo) = +proc pushInfoContext*(info: TLineInfo) = msgContext.add(info) - -proc popInfoContext*() = + +proc popInfoContext*() = setLen(msgContext, len(msgContext) - 1) proc getInfoContext*(index: int): TLineInfo = @@ -669,10 +669,10 @@ proc toMsgFilename*(info: TLineInfo): string = else: result = fileInfos[info.fileIndex].projPath -proc toLinenumber*(info: TLineInfo): int {.inline.} = +proc toLinenumber*(info: TLineInfo): int {.inline.} = result = info.line -proc toColumn*(info: TLineInfo): int {.inline.} = +proc toColumn*(info: TLineInfo): int {.inline.} = result = info.col proc toFileLine*(info: TLineInfo): string {.inline.} = @@ -689,11 +689,11 @@ proc `??`* (info: TLineInfo, filename: string): bool = var gTrackPos*: TLineInfo -proc outWriteln*(s: string) = +proc outWriteln*(s: string) = ## Writes to stdout. Always. if eStdOut in errorOutputs: writeln(stdout, s) - -proc msgWriteln*(s: string) = + +proc msgWriteln*(s: string) = ## Writes to stdout. If --stdout option is given, writes to stderr instead. #if gCmd == cmdIdeTools and optCDebug notin gGlobalOptions: return @@ -704,18 +704,18 @@ proc msgWriteln*(s: string) = if eStdErr in errorOutputs: writeln(stderr, s) else: if eStdOut in errorOutputs: writeln(stdout, s) - + if eInMemory in errorOutputs: bufferedMsgs.safeAdd(s) -proc coordToStr(coord: int): string = +proc coordToStr(coord: int): string = if coord == -1: result = "???" else: result = $coord - -proc msgKindToString*(kind: TMsgKind): string = + +proc msgKindToString*(kind: TMsgKind): string = # later versions may provide translated error messages result = MsgKindToStr[kind] -proc getMessageStr(msg: TMsgKind, arg: string): string = +proc getMessageStr(msg: TMsgKind, arg: string): string = result = msgKindToString(msg) % [arg] type @@ -745,34 +745,34 @@ proc handleError(msg: TMsgKind, eh: TErrorHandling, s: string) = proc `==`*(a, b: TLineInfo): bool = result = a.line == b.line and a.fileIndex == b.fileIndex -proc writeContext(lastinfo: TLineInfo) = +proc writeContext(lastinfo: TLineInfo) = var info = lastinfo - for i in countup(0, len(msgContext) - 1): - if msgContext[i] != lastinfo and msgContext[i] != info: - msgWriteln(PosContextFormat % [toMsgFilename(msgContext[i]), - coordToStr(msgContext[i].line), - coordToStr(msgContext[i].col), + for i in countup(0, len(msgContext) - 1): + if msgContext[i] != lastinfo and msgContext[i] != info: + msgWriteln(PosContextFormat % [toMsgFilename(msgContext[i]), + coordToStr(msgContext[i].line), + coordToStr(msgContext[i].col), getMessageStr(errInstantiationFrom, "")]) info = msgContext[i] proc ignoreMsgBecauseOfIdeTools(msg: TMsgKind): bool = msg >= errGenerated and gCmd == cmdIdeTools and optIdeDebug notin gGlobalOptions -proc rawMessage*(msg: TMsgKind, args: openArray[string]) = +proc rawMessage*(msg: TMsgKind, args: openArray[string]) = var frmt: string case msg - of errMin..errMax: + of errMin..errMax: writeContext(unknownLineInfo()) frmt = RawErrorFormat - of warnMin..warnMax: - if optWarns notin gOptions: return - if msg notin gNotes: return + of warnMin..warnMax: + if optWarns notin gOptions: return + if msg notin gNotes: return writeContext(unknownLineInfo()) frmt = RawWarningFormat inc(gWarnCounter) - of hintMin..hintMax: - if optHints notin gOptions: return - if msg notin gNotes: return + of hintMin..hintMax: + if optHints notin gOptions: return + if msg notin gNotes: return frmt = RawHintFormat inc(gHintCounter) let s = `%`(frmt, `%`(msgKindToString(msg), args)) @@ -780,7 +780,7 @@ proc rawMessage*(msg: TMsgKind, args: openArray[string]) = msgWriteln(s) handleError(msg, doAbort, s) -proc rawMessage*(msg: TMsgKind, arg: string) = +proc rawMessage*(msg: TMsgKind, arg: string) = rawMessage(msg, [arg]) proc writeSurroundingSrc(info: TLineInfo) = @@ -796,7 +796,7 @@ proc formatMsg*(info: TLineInfo, msg: TMsgKind, arg: string): string = result = frmt % [toMsgFilename(info), coordToStr(info.line), coordToStr(info.col), getMessageStr(msg, arg)] -proc liMessage(info: TLineInfo, msg: TMsgKind, arg: string, +proc liMessage(info: TLineInfo, msg: TMsgKind, arg: string, eh: TErrorHandling) = var frmt: string var ignoreMsg = false @@ -813,7 +813,7 @@ proc liMessage(info: TLineInfo, msg: TMsgKind, arg: string, if not ignoreMsg: writeContext(info) frmt = PosWarningFormat inc(gWarnCounter) - of hintMin..hintMax: + of hintMin..hintMax: ignoreMsg = optHints notin gOptions or msg notin gNotes frmt = PosHintFormat inc(gHintCounter) @@ -824,11 +824,11 @@ proc liMessage(info: TLineInfo, msg: TMsgKind, arg: string, if optPrintSurroundingSrc and msg in errMin..errMax: info.writeSurroundingSrc handleError(msg, eh, s) - -proc fatal*(info: TLineInfo, msg: TMsgKind, arg = "") = + +proc fatal*(info: TLineInfo, msg: TMsgKind, arg = "") = liMessage(info, msg, arg, doAbort) -proc globalError*(info: TLineInfo, msg: TMsgKind, arg = "") = +proc globalError*(info: TLineInfo, msg: TMsgKind, arg = "") = liMessage(info, msg, arg, doRaise) proc globalError*(info: TLineInfo, arg: string) = @@ -843,12 +843,12 @@ proc localError*(info: TLineInfo, arg: string) = proc message*(info: TLineInfo, msg: TMsgKind, arg = "") = liMessage(info, msg, arg, doNothing) -proc internalError*(info: TLineInfo, errMsg: string) = +proc internalError*(info: TLineInfo, errMsg: string) = if gCmd == cmdIdeTools: return writeContext(info) liMessage(info, errInternal, errMsg, doAbort) -proc internalError*(errMsg: string) = +proc internalError*(errMsg: string) = if gCmd == cmdIdeTools: return writeContext(unknownLineInfo()) rawMessage(errInternal, errMsg) @@ -865,7 +865,7 @@ proc addSourceLine*(fileIdx: int32, line: string) = proc sourceLine*(i: TLineInfo): PRope = if i.fileIndex < 0: return nil - + if not optPreserveOrigSource and fileInfos[i.fileIndex].lines.len == 0: try: for line in lines(i.toFullPath): diff --git a/compiler/parampatterns.nim b/compiler/parampatterns.nim index 8db786a25..58b5c5681 100644 --- a/compiler/parampatterns.nim +++ b/compiler/parampatterns.nim @@ -24,7 +24,7 @@ type ppEof = 1, # end of compiled pattern ppOr, # we could short-cut the evaluation for 'and' and 'or', ppAnd, # but currently we don't - ppNot, + ppNot, ppSym, ppAtom, ppLit, @@ -56,7 +56,7 @@ proc whichAlias*(p: PSym): TAliasRequest = proc compileConstraints(p: PNode, result: var TPatternCode) = case p.kind of nkCallKinds: - if p.sons[0].kind != nkIdent: + if p.sons[0].kind != nkIdent: patternError(p.sons[0]) return let op = p.sons[0].ident @@ -168,8 +168,8 @@ proc checkForSideEffects(n: PNode): TSideEffectAnalysis = elif ret == seUnknown and result == seNoSideEffect: result = seUnknown -type - TAssignableResult* = enum +type + TAssignableResult* = enum arNone, # no l-value and no discriminant arLValue, # is an l-value arLocalLValue, # is an l-value, but local var; must not escape @@ -183,26 +183,26 @@ proc isAssignable*(owner: PSym, n: PNode): TAssignableResult = of nkSym: # don't list 'skLet' here: if n.sym.kind in {skVar, skResult, skTemp}: - if owner != nil and owner.id == n.sym.owner.id and + if owner != nil and owner.id == n.sym.owner.id and sfGlobal notin n.sym.flags: result = arLocalLValue else: result = arLValue - of nkDotExpr: - if skipTypes(n.sons[0].typ, abstractInst-{tyTypeDesc}).kind in - {tyVar, tyPtr, tyRef}: + of nkDotExpr: + if skipTypes(n.sons[0].typ, abstractInst-{tyTypeDesc}).kind in + {tyVar, tyPtr, tyRef}: result = arLValue else: result = isAssignable(owner, n.sons[0]) - if result != arNone and sfDiscriminant in n.sons[1].sym.flags: + if result != arNone and sfDiscriminant in n.sons[1].sym.flags: result = arDiscriminant - of nkBracketExpr: + of nkBracketExpr: if skipTypes(n.sons[0].typ, abstractInst-{tyTypeDesc}).kind in - {tyVar, tyPtr, tyRef}: + {tyVar, tyPtr, tyRef}: result = arLValue else: result = isAssignable(owner, n.sons[0]) - of nkHiddenStdConv, nkHiddenSubConv, nkConv: + of nkHiddenStdConv, nkHiddenSubConv, nkConv: # Object and tuple conversions are still addressable, so we skip them # XXX why is 'tyOpenArray' allowed here? if skipTypes(n.typ, abstractPtrs-{tyTypeDesc}).kind in @@ -211,9 +211,9 @@ proc isAssignable*(owner: PSym, n: PNode): TAssignableResult = elif compareTypes(n.typ, n.sons[1].typ, dcEqIgnoreDistinct): # types that are equal modulo distinction preserve l-value: result = isAssignable(owner, n.sons[1]) - of nkHiddenDeref, nkDerefExpr: + of nkHiddenDeref, nkDerefExpr, nkHiddenAddr: result = arLValue - of nkObjUpConv, nkObjDownConv, nkCheckedFieldExpr: + of nkObjUpConv, nkObjDownConv, nkCheckedFieldExpr: result = isAssignable(owner, n.sons[0]) of nkCallKinds: # builtin slice keeps lvalue-ness: @@ -221,24 +221,27 @@ proc isAssignable*(owner: PSym, n: PNode): TAssignableResult = else: discard +proc isLValue*(n: PNode): bool = + isAssignable(nil, n) in {arLValue, arLocalLValue} + proc matchNodeKinds*(p, n: PNode): bool = - # matches the parameter constraint 'p' against the concrete AST 'n'. + # matches the parameter constraint 'p' against the concrete AST 'n'. # Efficiency matters here. var stack {.noinit.}: array[0..MaxStackSize, bool] # empty patterns are true: stack[0] = true var sp = 1 - + template push(x: bool) = stack[sp] = x inc sp - + let code = p.strVal var pc = 1 while true: case TOpcode(code[pc]) of ppEof: break - of ppOr: + of ppOr: stack[sp-2] = stack[sp-1] or stack[sp-2] dec sp of ppAnd: @@ -264,4 +267,4 @@ proc matchNodeKinds*(p, n: PNode): bool = of ppNoSideEffect: push checkForSideEffects(n) != seSideEffect inc pc result = stack[sp-1] - + diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 3d2ba2568..d236687c3 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1907,12 +1907,11 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode = var ids = initIntSet() for i in 1.. <n.len: let it = n.sons[i] - if it.kind != nkExprColonExpr or it.sons[0].kind notin {nkSym, nkIdent}: + if it.kind != nkExprColonExpr: localError(n.info, errNamedExprExpected) break - var id: PIdent - if it.sons[0].kind == nkIdent: id = it.sons[0].ident - else: id = it.sons[0].sym.name + let id = considerQuotedIdent(it.sons[0]) + if containsOrIncl(ids, id.id): localError(it.info, errFieldInitTwice, id.s) var e = semExprWithType(c, it.sons[1], flags*{efAllowDestructor}) diff --git a/compiler/semparallel.nim b/compiler/semparallel.nim index 6572a7f49..fbcd6b6da 100644 --- a/compiler/semparallel.nim +++ b/compiler/semparallel.nim @@ -317,8 +317,9 @@ proc analyseIf(c: var AnalysisCtx; n: PNode) = proc analyse(c: var AnalysisCtx; n: PNode) = case n.kind of nkAsgn, nkFastAsgn: - if n[0].isSingleAssignable and n[1].isLocal: - let slot = c.getSlot(n[1].sym) + let y = n[1].skipConv + if n[0].isSingleAssignable and y.isLocal: + let slot = c.getSlot(y.sym) slot.alias = n[0].sym elif n[0].isLocal: # since we already ensure sfAddrTaken is not in s.flags, we only need to @@ -334,7 +335,7 @@ proc analyse(c: var AnalysisCtx; n: PNode) = analyse(c, n[0]) else: analyseSons(c, n) - addAsgnFact(c.guards, n[0], n[1]) + addAsgnFact(c.guards, n[0], y) of nkCallKinds: # direct call: if n[0].kind == nkSym: analyseCall(c, n, n[0].sym) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index f1fd84326..e56d82a5b 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -191,21 +191,6 @@ proc complexDisambiguation(a, b: PType): int = for i in 1 .. <a.len: x += a.sons[i].sumGeneric for i in 1 .. <b.len: y += b.sons[i].sumGeneric result = x - y - when false: - proc betterThan(a, b: PType): bool {.inline.} = a.sumGeneric > b.sumGeneric - - if a.len > 1 and b.len > 1: - let aa = a.sons[1].sumGeneric - let bb = b.sons[1].sumGeneric - var a = a - var b = b - - if aa < bb: swap(a, b) - # all must be better - for i in 2 .. <min(a.len, b.len): - if not a.sons[i].betterThan(b.sons[i]): return 0 - # a must be longer or of the same length as b: - result = a.len - b.len proc cmpCandidates*(a, b: TCandidate): int = result = a.exactMatches - b.exactMatches @@ -1463,6 +1448,12 @@ proc matchesAux(c: PContext, n, nOrig: PNode, else: m.state = csNoMatch return + if formal.typ.kind == tyVar: + if n.isLValue: + inc(m.genericMatches, 100) + else: + m.state = csNoMatch + return var # iterates over formal parameters diff --git a/compiler/vm.nim b/compiler/vm.nim index f0a0135e8..3b5c8e7f3 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -814,7 +814,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = leValueConv(regs[ra].regToNode, regs[rc].regToNode)): stackTrace(c, tos, pc, errGenerated, msgKindToString(errIllegalConvFromXtoY) % [ - "unknown type" , "unknown type"]) + $regs[ra].regToNode, "[" & $regs[rb].regToNode & ".." & $regs[rc].regToNode & "]"]) of opcIndCall, opcIndCallAsgn: # dest = call regStart, n; where regStart = fn, arg1, ... let rb = instr.regB diff --git a/doc/advopt.txt b/doc/advopt.txt index d4b1b7e57..195122cc7 100644 --- a/doc/advopt.txt +++ b/doc/advopt.txt @@ -12,19 +12,6 @@ Advanced commands: module dependency graph //dump dump all defined conditionals and search paths //check checks the project for syntax and semantic - //idetools compiler support for IDEs: possible options: - --track:FILE,LINE,COL track a file/cursor position - --trackDirty:DIRTY_FILE,ORIG_FILE,LINE,COL - track a file, currently not saved to disk - --suggest suggest all possible symbols at position - --def list all possible definitions at position - --context list possible invocation context - --usages list all usages of the symbol at position - --eval evaluates an expression - //serve start the compiler as a service mode (CAAS) - --server.type:TYPE either stdin or tcp - --server.port:PORT port for tcp mode, by default 6000 - --server.address:HOST binds to that address, by default "" Advanced options: -o, --out:FILE set the output filename @@ -81,7 +68,7 @@ Advanced options: --dynlibOverride:SYMBOL marks SYMBOL so that dynlib:SYMBOL has no effect and can be statically linked instead; symbol matching is fuzzy so - that --dynlibOverride:lua matches + that --dynlibOverride:lua matches dynlib: "liblua.so.3" --listCmd list the commands used to execute external programs --parallelBuild:0|1|... perform a parallel build diff --git a/doc/basicopt.txt b/doc/basicopt.txt index 7d08f1159..6a905bd53 100644 --- a/doc/basicopt.txt +++ b/doc/basicopt.txt @@ -29,6 +29,7 @@ Options: --infChecks:on|off turn Inf checks on|off --deadCodeElim:on|off whole program dead code elimination on|off --opt:none|speed|size optimize not at all or for speed|size + Note: use -d:release for a release build! --debugger:native|endb use native debugger (gdb) | ENDB (experimental) --app:console|gui|lib|staticlib generate a console app|GUI app|DLL|static library diff --git a/doc/manual/type_rel.txt b/doc/manual/type_rel.txt index 74539f907..d1593a02e 100644 --- a/doc/manual/type_rel.txt +++ b/doc/manual/type_rel.txt @@ -18,7 +18,7 @@ algorithm (in pseudo-code) determines type equality: incl(s, (a,b)) if a.kind == b.kind: case a.kind - of int, intXX, float, floatXX, char, string, cstring, pointer, + of int, intXX, float, floatXX, char, string, cstring, pointer, bool, nil, void: # leaf type: kinds identical; nothing more to check result = true @@ -61,7 +61,7 @@ with an auxiliary set ``s`` is omitted: proc typeEqualsOrDistinct(a, b: PType): bool = if a.kind == b.kind: case a.kind - of int, intXX, float, floatXX, char, string, cstring, pointer, + of int, intXX, float, floatXX, char, string, cstring, pointer, bool, nil, void: # leaf type: kinds identical; nothing more to check result = true @@ -90,7 +90,7 @@ with an auxiliary set ``s`` is omitted: result = typeEqualsOrDistinct(a.baseType, b) elif b.kind == distinct: result = typeEqualsOrDistinct(a, b.baseType) - + Subtype relation ---------------- @@ -145,7 +145,7 @@ algorithm returns true: A type ``a`` is **explicitly** convertible to type ``b`` iff the following algorithm returns true: - + .. code-block:: nim proc isIntegralType(t: PType): bool = result = isOrdinal(t) or t.kind in {float, float32, float64} @@ -156,8 +156,8 @@ algorithm returns true: if typeEqualsOrDistinct(a, b): return true if isIntegralType(a) and isIntegralType(b): return true if isSubtype(a, b) or isSubtype(b, a): return true - -The convertible relation can be relaxed by a user-defined type + +The convertible relation can be relaxed by a user-defined type `converter`:idx:. .. code-block:: nim @@ -174,7 +174,7 @@ The convertible relation can be relaxed by a user-defined type x = chr.toInt echo x # => 97 -The type conversion ``T(a)`` is an L-value if ``a`` is an L-value and +The type conversion ``T(a)`` is an L-value if ``a`` is an L-value and ``typeEqualsOrDistinct(T, type(a))`` holds. @@ -186,6 +186,157 @@ An expression ``b`` can be assigned to an expression ``a`` iff ``a`` is an Overloading resolution ----------------------- +====================== + +In a call ``p(args)`` the routine ``p`` that matches best is selected. If +multiple routines match equally well, the ambiguity is reported at compiletime. + +Every arg in args needs to match. There are multiple different category how an +argument can match. Let ``f`` be the formal parameter's type and ``a`` the type +of the argument. + +1. Exact match: ``a`` and ``f`` are of the same type. +2. Literal match: ``a`` is an integer literal of value ``v`` + and ``f`` is a signed or unsigned integer type and ``v`` is in ``f``'s + range. Or: ``a`` is a floating point literal of value ``v`` + and ``f`` is a floating point type and ``v`` is in ``f``'s + range. +3. Generic match: ``f`` is a generic type and ``a`` matches, for + instance ``a`` is ``int`` and ``f`` is a generic (constrained) parameter + type (like in ``[T]`` or ``[T: int|char]``. +4. Subrange or subtype match: ``a`` is a ``range[T]`` and ``T`` + matches ``f`` exactly. Or: ``a`` is a subtype of ``f``. +5. Integral conversion match: ``a`` is convertible to ``f`` and ``f`` and ``a`` + is some integer or floating point type. +6. Conversion match: ``a`` is convertible to ``f``, possibly via a user + defined ``converter``. + +These matching categories have a priority: An exact match is better than a +literal match and that is better than a generic match etc. In the following +``count(p, m)`` counts the number of matches of the matching category ``m`` +for the routine ``p``. + +A routine ``p`` matches better than a routine ``q`` if the following +algorithm returns true:: + + for each matching category m in ["exact match", "literal match", + "generic match", "subtype match", + "integral match", "conversion match"]: + if count(p, m) > count(q, m): return true + elif count(p, m) == count(q, m): + discard "continue with next category m" + else: + return false + return "ambiguous" + + +Some examples: + +.. code-block:: nim + proc takesInt(x: int) = echo "int" + proc takesInt[T](x: T) = echo "T" + proc takesInt(x: int16) = echo "int16" + + takesInt(4) # "int" + var x: int32 + takesInt(x) # "T" + var y: int16 + takesInt(y) # "int16" + var z: range[0..4] = 0 + takesInt(z) # "T" + + +If this algorithm returns "ambiguous" further disambiguation is performed: +If the argument ``a`` matches both the parameter type ``f`` of ``p`` +and ``g`` of ``q`` via a subtyping relation, the inheritance depth is taken +into account: + +.. code-block:: nim + type + A = object of RootObj + B = object of A + C = object of B + + proc p(obj: A) = + echo "A" + + proc p(obj: B) = + echo "B" + + var c = C() + # not ambiguous, calls 'B', not 'A' since B is a subtype of A + # but not vice versa: + p(c) + + proc pp(obj: A, obj2: B) = echo "A B" + proc pp(obj: B, obj2: A) = echo "B A" + + # but this is ambiguous: + pp(c, c) + + +Likewise for generic matches the most specialized generic type (that still +matches) is preferred: + +.. code-block:: nim + proc gen[T](x: ref ref T) = echo "ref ref T" + proc gen[T](x: ref T) = echo "ref T" + proc gen[T](x: T) = echo "T" + + var ri: ref int + gen(ri) # "ref T" + + +Overloading based on 'var T' +---------------------------- + +If the formal parameter ``f`` is of type ``var T`` in addition to the ordinary +type checking, the argument is checked to be an `l-value`:idx:. ``var T`` +matches better than just ``T`` then. + + +Automatic dereferencing +----------------------- + +If the `experimental mode <experimental pragma>`_ is active and no other match +is found, the first argument ``a`` is dereferenced automatically if it's a +pointer type and overloading resolution is tried with ``a[]`` instead. + + +Lazy type resolution for expr +----------------------------- + +**Note**: An `unresolved`:idx: expression is an expression for which no symbol +lookups and no type checking have been performed. + +Since templates and macros that are not declared as ``immediate`` participate +in overloading resolution it's essential to have a way to pass unresolved +expressions to a template or macro. This is what the meta-type ``expr`` +accomplishes: + +.. code-block:: nim + template rem(x: expr) = discard + + rem unresolvedExpression(undeclaredIdentifier) + +A parameter of type ``expr`` always matches any argument (as long as there is +any argument passed to it). + +But one has to watch out because other overloads might trigger the +argument's resolution: + +.. code-block:: nim + template rem(x: expr) = discard + proc rem[T](x: T) = discard + + # undeclared identifier: 'unresolvedExpression' + rem unresolvedExpression(undeclaredIdentifier) + +``expr`` is the only metatype that is lazy in this sense, the other +metatypes ``stmt`` and ``typedesc`` are not lazy. + + +Varargs matching +---------------- -To be written. +See `Varargs`_. diff --git a/doc/manual/types.txt b/doc/manual/types.txt index a20701121..c78984db8 100644 --- a/doc/manual/types.txt +++ b/doc/manual/types.txt @@ -497,6 +497,24 @@ type conversions in this context: In this example ``$`` is applied to any argument that is passed to the parameter ``a``. (Note that ``$`` applied to strings is a nop.) +Note that an explicit array constructor passed to a ``varargs`` parameter is +not wrapped in another implicit array construction: + +.. code-block:: nim + proc takeV[T](a: varargs[T]) = discard + + takeV([123, 2, 1]) # takeV's T is "int", not "array of int" + + +``varargs[expr]`` is treated specially: It matches a variable list of arguments +of arbitrary type but *always* constructs an implicit array. This is required +so that the builtin ``echo`` proc does what is expected: + +.. code-block:: nim + proc echo*(x: varargs[expr, `$`]) {...} + + echo(@[1, 2, 3]) + # prints "@[1, 2, 3]" and not "123" Tuples and object types @@ -695,7 +713,7 @@ via ``{.experimental.}``: new(n) echo n.depth # no need to write n[].depth either - + In order to simplify structural type checking, recursive tuples are not valid: diff --git a/lib/impure/osinfo_posix.nim b/lib/impure/osinfo_posix.nim index 0ed4289c4..0362fca12 100644 --- a/lib/impure/osinfo_posix.nim +++ b/lib/impure/osinfo_posix.nim @@ -1,77 +1,10 @@ -import posix, strutils, os - -when false: - type - Tstatfs {.importc: "struct statfs64", - header: "<sys/statfs.h>", final, pure.} = object - f_type: int - f_bsize: int - f_blocks: int - f_bfree: int - f_bavail: int - f_files: int - f_ffree: int - f_fsid: int - f_namelen: int - - proc statfs(path: string, buf: var Tstatfs): int {. - importc, header: "<sys/vfs.h>".} - - -proc getSystemVersion*(): string = - result = "" - - var unix_info: TUtsname - - if uname(unix_info) != 0: - os.raiseOSError(osLastError()) - - if $unix_info.sysname == "Linux": - # Linux - result.add("Linux ") - - result.add($unix_info.release & " ") - result.add($unix_info.machine) - elif $unix_info.sysname == "Darwin": - # Darwin - result.add("Mac OS X ") - if "14" in $unix_info.release: - result.add("v10.10 Yosemite") - elif "13" in $unix_info.release: - result.add("v10.9 Mavericks") - elif "12" in $unix_info.release: - result.add("v10.8 Mountian Lion") - elif "11" in $unix_info.release: - result.add("v10.7 Lion") - elif "10" in $unix_info.release: - result.add("v10.6 Snow Leopard") - elif "9" in $unix_info.release: - result.add("v10.5 Leopard") - elif "8" in $unix_info.release: - result.add("v10.4 Tiger") - elif "7" in $unix_info.release: - result.add("v10.3 Panther") - elif "6" in $unix_info.release: - result.add("v10.2 Jaguar") - elif "1.4" in $unix_info.release: - result.add("v10.1 Puma") - elif "1.3" in $unix_info.release: - result.add("v10.0 Cheetah") - elif "0" in $unix_info.release: - result.add("Server 1.0 Hera") - else: - result.add($unix_info.sysname & " " & $unix_info.release) - - -when false: - var unix_info: TUtsname - echo(uname(unix_info)) - echo(unix_info.sysname) - echo("8" in $unix_info.release) - - echo(getSystemVersion()) - - var stfs: TStatfs - echo(statfs("sysinfo_posix.nim", stfs)) - echo(stfs.f_files) - +# +# +# Nim's Runtime Library +# (c) Copyright 2015 Dominik Picheta +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +{.error: "This module has been moved to the 'osinfo' nimble package.".} diff --git a/lib/impure/osinfo_win.nim b/lib/impure/osinfo_win.nim index 94a27eb03..0362fca12 100644 --- a/lib/impure/osinfo_win.nim +++ b/lib/impure/osinfo_win.nim @@ -1,411 +1,10 @@ -# XXX clean up this mess! - -import winlean - -const - INVALID_HANDLE_VALUE = int(- 1) # GetStockObject - -type - TMEMORYSTATUSEX {.final, pure.} = object - dwLength: int32 - dwMemoryLoad: int32 - ullTotalPhys: int64 - ullAvailPhys: int64 - ullTotalPageFile: int64 - ullAvailPageFile: int64 - ullTotalVirtual: int64 - ullAvailVirtual: int64 - ullAvailExtendedVirtual: int64 - - SYSTEM_INFO* {.final, pure.} = object - wProcessorArchitecture*: int16 - wReserved*: int16 - dwPageSize*: int32 - lpMinimumApplicationAddress*: pointer - lpMaximumApplicationAddress*: pointer - dwActiveProcessorMask*: int32 - dwNumberOfProcessors*: int32 - dwProcessorType*: int32 - dwAllocationGranularity*: int32 - wProcessorLevel*: int16 - wProcessorRevision*: int16 - - LPSYSTEM_INFO* = ptr SYSTEM_INFO - TSYSTEMINFO* = SYSTEM_INFO - - TMemoryInfo* = object - MemoryLoad*: int ## occupied memory, in percent - TotalPhysMem*: int64 ## Total Physical memory, in bytes - AvailablePhysMem*: int64 ## Available physical memory, in bytes - TotalPageFile*: int64 ## The current committed memory limit - ## for the system or the current process, whichever is smaller, in bytes. - AvailablePageFile*: int64 ## The maximum amount of memory the current process can commit, in bytes. - TotalVirtualMem*: int64 ## Total virtual memory, in bytes - AvailableVirtualMem*: int64 ## Available virtual memory, in bytes - - TOSVERSIONINFOEX {.final, pure.} = object - dwOSVersionInfoSize: int32 - dwMajorVersion: int32 - dwMinorVersion: int32 - dwBuildNumber: int32 - dwPlatformId: int32 - szCSDVersion: array[0..127, char] - wServicePackMajor: int16 - wServicePackMinor: int16 - wSuiteMask: int16 - wProductType: int8 - wReserved: char - - TVersionInfo* = object - majorVersion*: int - minorVersion*: int - buildNumber*: int - platformID*: int - SPVersion*: string ## Full Service pack version string - SPMajor*: int ## Major service pack version - SPMinor*: int ## Minor service pack version - SuiteMask*: int - ProductType*: int - - TPartitionInfo* = tuple[FreeSpace, TotalSpace: Tfiletime] - -const - # SuiteMask - VersionInfo.SuiteMask - VER_SUITE_BACKOFFICE* = 0x00000004 - VER_SUITE_BLADE* = 0x00000400 - VER_SUITE_COMPUTE_SERVER* = 0x00004000 - VER_SUITE_DATACENTER* = 0x00000080 - VER_SUITE_ENTERPRISE* = 0x00000002 - VER_SUITE_EMBEDDEDNT* = 0x00000040 - VER_SUITE_PERSONAL* = 0x00000200 - VER_SUITE_SINGLEUSERTS* = 0x00000100 - VER_SUITE_SMALLBUSINESS* = 0x00000001 - VER_SUITE_SMALLBUSINESS_RESTRICTED* = 0x00000020 - VER_SUITE_STORAGE_SERVER* = 0x00002000 - VER_SUITE_TERMINAL* = 0x00000010 - VER_SUITE_WH_SERVER* = 0x00008000 - - # ProductType - VersionInfo.ProductType - VER_NT_DOMAIN_CONTROLLER* = 0x0000002 - VER_NT_SERVER* = 0x0000003 - VER_NT_WORKSTATION* = 0x0000001 - - VER_PLATFORM_WIN32_NT* = 2 - - # Product Info - getProductInfo() - (Remove unused ones ?) - PRODUCT_BUSINESS* = 0x00000006 - PRODUCT_BUSINESS_N* = 0x00000010 - PRODUCT_CLUSTER_SERVER* = 0x00000012 - PRODUCT_DATACENTER_SERVER* = 0x00000008 - PRODUCT_DATACENTER_SERVER_CORE* = 0x0000000C - PRODUCT_DATACENTER_SERVER_CORE_V* = 0x00000027 - PRODUCT_DATACENTER_SERVER_V* = 0x00000025 - PRODUCT_ENTERPRISE* = 0x00000004 - PRODUCT_ENTERPRISE_E* = 0x00000046 - PRODUCT_ENTERPRISE_N* = 0x0000001B - PRODUCT_ENTERPRISE_SERVER* = 0x0000000A - PRODUCT_ENTERPRISE_SERVER_CORE* = 0x0000000E - PRODUCT_ENTERPRISE_SERVER_CORE_V* = 0x00000029 - PRODUCT_ENTERPRISE_SERVER_IA64* = 0x0000000F - PRODUCT_ENTERPRISE_SERVER_V* = 0x00000026 - PRODUCT_HOME_BASIC* = 0x00000002 - PRODUCT_HOME_BASIC_E* = 0x00000043 - PRODUCT_HOME_BASIC_N* = 0x00000005 - PRODUCT_HOME_PREMIUM* = 0x00000003 - PRODUCT_HOME_PREMIUM_E* = 0x00000044 - PRODUCT_HOME_PREMIUM_N* = 0x0000001A - PRODUCT_HYPERV* = 0x0000002A - PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT* = 0x0000001E - PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING* = 0x00000020 - PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY* = 0x0000001F - PRODUCT_PROFESSIONAL* = 0x00000030 - PRODUCT_PROFESSIONAL_E* = 0x00000045 - PRODUCT_PROFESSIONAL_N* = 0x00000031 - PRODUCT_SERVER_FOR_SMALLBUSINESS* = 0x00000018 - PRODUCT_SERVER_FOR_SMALLBUSINESS_V* = 0x00000023 - PRODUCT_SERVER_FOUNDATION* = 0x00000021 - PRODUCT_SMALLBUSINESS_SERVER* = 0x00000009 - PRODUCT_STANDARD_SERVER* = 0x00000007 - PRODUCT_STANDARD_SERVER_CORE * = 0x0000000D - PRODUCT_STANDARD_SERVER_CORE_V* = 0x00000028 - PRODUCT_STANDARD_SERVER_V* = 0x00000024 - PRODUCT_STARTER* = 0x0000000B - PRODUCT_STARTER_E* = 0x00000042 - PRODUCT_STARTER_N* = 0x0000002F - PRODUCT_STORAGE_ENTERPRISE_SERVER* = 0x00000017 - PRODUCT_STORAGE_EXPRESS_SERVER* = 0x00000014 - PRODUCT_STORAGE_STANDARD_SERVER* = 0x00000015 - PRODUCT_STORAGE_WORKGROUP_SERVER* = 0x00000016 - PRODUCT_UNDEFINED* = 0x00000000 - PRODUCT_ULTIMATE* = 0x00000001 - PRODUCT_ULTIMATE_E* = 0x00000047 - PRODUCT_ULTIMATE_N* = 0x0000001C - PRODUCT_WEB_SERVER* = 0x00000011 - PRODUCT_WEB_SERVER_CORE* = 0x0000001D - - PROCESSOR_ARCHITECTURE_AMD64* = 9 ## x64 (AMD or Intel) - PROCESSOR_ARCHITECTURE_IA64* = 6 ## Intel Itanium Processor Family (IPF) - PROCESSOR_ARCHITECTURE_INTEL* = 0 ## x86 - PROCESSOR_ARCHITECTURE_UNKNOWN* = 0xffff ## Unknown architecture. - - # GetSystemMetrics - SM_SERVERR2 = 89 - -proc globalMemoryStatusEx*(lpBuffer: var TMEMORYSTATUSEX){.stdcall, dynlib: "kernel32", - importc: "GlobalMemoryStatusEx".} - -proc getMemoryInfo*(): TMemoryInfo = - ## Retrieves memory info - var statex: TMEMORYSTATUSEX - statex.dwLength = sizeof(statex).int32 - - globalMemoryStatusEx(statex) - result.MemoryLoad = statex.dwMemoryLoad - result.TotalPhysMem = statex.ullTotalPhys - result.AvailablePhysMem = statex.ullAvailPhys - result.TotalPageFile = statex.ullTotalPageFile - result.AvailablePageFile = statex.ullAvailPageFile - result.TotalVirtualMem = statex.ullTotalVirtual - result.AvailableVirtualMem = statex.ullAvailExtendedVirtual - -proc getVersionEx*(lpVersionInformation: var TOSVERSIONINFOEX): WINBOOL{.stdcall, - dynlib: "kernel32", importc: "GetVersionExA".} - -proc getProcAddress*(hModule: int, lpProcName: cstring): pointer{.stdcall, - dynlib: "kernel32", importc: "GetProcAddress".} - -proc getModuleHandleA*(lpModuleName: cstring): int{.stdcall, - dynlib: "kernel32", importc: "GetModuleHandleA".} - -proc getVersionInfo*(): TVersionInfo = - ## Retrieves operating system info - var osvi: TOSVERSIONINFOEX - osvi.dwOSVersionInfoSize = sizeof(osvi).int32 - discard getVersionEx(osvi) - result.majorVersion = osvi.dwMajorVersion - result.minorVersion = osvi.dwMinorVersion - result.buildNumber = osvi.dwBuildNumber - result.platformID = osvi.dwPlatformId - result.SPVersion = $osvi.szCSDVersion - result.SPMajor = osvi.wServicePackMajor - result.SPMinor = osvi.wServicePackMinor - result.SuiteMask = osvi.wSuiteMask - result.ProductType = osvi.wProductType - -proc getProductInfo*(majorVersion, minorVersion, SPMajorVersion, - SPMinorVersion: int): int = - ## Retrieves Windows' ProductInfo, this function only works in Vista and 7 - var pGPI = cast[proc (dwOSMajorVersion, dwOSMinorVersion, - dwSpMajorVersion, dwSpMinorVersion: int32, outValue: Pint32){.stdcall.}](getProcAddress( - getModuleHandleA("kernel32.dll"), "GetProductInfo")) - - if pGPI != nil: - var dwType: int32 - pGPI(int32(majorVersion), int32(minorVersion), int32(SPMajorVersion), int32(SPMinorVersion), addr(dwType)) - result = int(dwType) - else: - return PRODUCT_UNDEFINED - -proc getSystemInfo*(lpSystemInfo: LPSYSTEM_INFO){.stdcall, dynlib: "kernel32", - importc: "GetSystemInfo".} - -proc getSystemInfo*(): TSYSTEM_INFO = - ## Returns the SystemInfo - - # Use GetNativeSystemInfo if it's available - var pGNSI = cast[proc (lpSystemInfo: LPSYSTEM_INFO){.stdcall.}](getProcAddress( - getModuleHandleA("kernel32.dll"), "GetNativeSystemInfo")) - - var systemi: TSYSTEM_INFO - if pGNSI != nil: - pGNSI(addr(systemi)) - else: - getSystemInfo(addr(systemi)) - - return systemi - -proc getSystemMetrics*(nIndex: int32): int32{.stdcall, dynlib: "user32", - importc: "GetSystemMetrics".} - -proc `$`*(osvi: TVersionInfo): string = - ## Turns a VersionInfo object, into a string - - if osvi.platformID == VER_PLATFORM_WIN32_NT and osvi.majorVersion > 4: - result = "Microsoft " - - var si = getSystemInfo() - # Test for the specific product - if osvi.majorVersion == 6: - if osvi.minorVersion == 0: - if osvi.ProductType == VER_NT_WORKSTATION: - result.add("Windows Vista ") - else: result.add("Windows Server 2008 ") - elif osvi.minorVersion == 1: - if osvi.ProductType == VER_NT_WORKSTATION: - result.add("Windows 7 ") - else: result.add("Windows Server 2008 R2 ") - elif osvi.minorVersion == 2: - if osvi.ProductType == VER_NT_WORKSTATION: - result.add("Windows 8 ") - else: result.add("Windows Server 2012 ") - elif osvi.minorVersion == 3: - if osvi.ProductType == VER_NT_WORKSTATION: - result.add("Windows 8.1 ") - else: result.add("Windows Server 2012 R2 ") - - var dwType = getProductInfo(osvi.majorVersion, osvi.minorVersion, 0, 0) - case dwType - of PRODUCT_ULTIMATE: - result.add("Ultimate Edition") - of PRODUCT_PROFESSIONAL: - result.add("Professional") - of PRODUCT_HOME_PREMIUM: - result.add("Home Premium Edition") - of PRODUCT_HOME_BASIC: - result.add("Home Basic Edition") - of PRODUCT_ENTERPRISE: - result.add("Enterprise Edition") - of PRODUCT_BUSINESS: - result.add("Business Edition") - of PRODUCT_STARTER: - result.add("Starter Edition") - of PRODUCT_CLUSTER_SERVER: - result.add("Cluster Server Edition") - of PRODUCT_DATACENTER_SERVER: - result.add("Datacenter Edition") - of PRODUCT_DATACENTER_SERVER_CORE: - result.add("Datacenter Edition (core installation)") - of PRODUCT_ENTERPRISE_SERVER: - result.add("Enterprise Edition") - of PRODUCT_ENTERPRISE_SERVER_CORE: - result.add("Enterprise Edition (core installation)") - of PRODUCT_ENTERPRISE_SERVER_IA64: - result.add("Enterprise Edition for Itanium-based Systems") - of PRODUCT_SMALLBUSINESS_SERVER: - result.add("Small Business Server") - of PRODUCT_STANDARD_SERVER: - result.add("Standard Edition") - of PRODUCT_STANDARD_SERVER_CORE: - result.add("Standard Edition (core installation)") - of PRODUCT_WEB_SERVER: - result.add("Web Server Edition") - else: - discard - # End of Windows 6.* - - if osvi.majorVersion == 5 and osvi.minorVersion == 2: - if getSystemMetrics(SM_SERVERR2) != 0: - result.add("Windows Server 2003 R2, ") - elif (osvi.SuiteMask and VER_SUITE_PERSONAL) != 0: # Not sure if this will work - result.add("Windows Storage Server 2003") - elif (osvi.SuiteMask and VER_SUITE_WH_SERVER) != 0: - result.add("Windows Home Server") - elif osvi.ProductType == VER_NT_WORKSTATION and - si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64: - result.add("Windows XP Professional x64 Edition") - else: - result.add("Windows Server 2003, ") - - # Test for the specific product - if osvi.ProductType != VER_NT_WORKSTATION: - if ze(si.wProcessorArchitecture) == PROCESSOR_ARCHITECTURE_IA64: - if (osvi.SuiteMask and VER_SUITE_DATACENTER) != 0: - result.add("Datacenter Edition for Itanium-based Systems") - elif (osvi.SuiteMask and VER_SUITE_ENTERPRISE) != 0: - result.add("Enterprise Edition for Itanium-based Systems") - elif ze(si.wProcessorArchitecture) == PROCESSOR_ARCHITECTURE_AMD64: - if (osvi.SuiteMask and VER_SUITE_DATACENTER) != 0: - result.add("Datacenter x64 Edition") - elif (osvi.SuiteMask and VER_SUITE_ENTERPRISE) != 0: - result.add("Enterprise x64 Edition") - else: - result.add("Standard x64 Edition") - else: - if (osvi.SuiteMask and VER_SUITE_COMPUTE_SERVER) != 0: - result.add("Compute Cluster Edition") - elif (osvi.SuiteMask and VER_SUITE_DATACENTER) != 0: - result.add("Datacenter Edition") - elif (osvi.SuiteMask and VER_SUITE_ENTERPRISE) != 0: - result.add("Enterprise Edition") - elif (osvi.SuiteMask and VER_SUITE_BLADE) != 0: - result.add("Web Edition") - else: - result.add("Standard Edition") - # End of 5.2 - - if osvi.majorVersion == 5 and osvi.minorVersion == 1: - result.add("Windows XP ") - if (osvi.SuiteMask and VER_SUITE_PERSONAL) != 0: - result.add("Home Edition") - else: - result.add("Professional") - # End of 5.1 - - if osvi.majorVersion == 5 and osvi.minorVersion == 0: - result.add("Windows 2000 ") - if osvi.ProductType == VER_NT_WORKSTATION: - result.add("Professional") - else: - if (osvi.SuiteMask and VER_SUITE_DATACENTER) != 0: - result.add("Datacenter Server") - elif (osvi.SuiteMask and VER_SUITE_ENTERPRISE) != 0: - result.add("Advanced Server") - else: - result.add("Server") - # End of 5.0 - - # Include service pack (if any) and build number. - if len(osvi.SPVersion) > 0: - result.add(" ") - result.add(osvi.SPVersion) - - result.add(" (build " & $osvi.buildNumber & ")") - - if osvi.majorVersion >= 6: - if ze(si.wProcessorArchitecture) == PROCESSOR_ARCHITECTURE_AMD64: - result.add(", 64-bit") - elif ze(si.wProcessorArchitecture) == PROCESSOR_ARCHITECTURE_INTEL: - result.add(", 32-bit") - - else: - # Windows 98 etc... - result = "Unknown version of windows[Kernel version <= 4]" - - -proc getFileSize*(file: string): BiggestInt = - var fileData: TWIN32_FIND_DATA - - when useWinUnicode: - var aa = newWideCString(file) - var hFile = findFirstFileW(aa, fileData) - else: - var hFile = findFirstFileA(file, fileData) - - if hFile == INVALID_HANDLE_VALUE: - raise newException(IOError, $getLastError()) - - return fileData.nFileSizeLow - -proc getDiskFreeSpaceEx*(lpDirectoryName: cstring, lpFreeBytesAvailableToCaller, - lpTotalNumberOfBytes, - lpTotalNumberOfFreeBytes: var TFiletime): WINBOOL{. - stdcall, dynlib: "kernel32", importc: "GetDiskFreeSpaceExA".} - -proc getPartitionInfo*(partition: string): TPartitionInfo = - ## Retrieves partition info, for example ``partition`` may be ``"C:\"`` - var freeBytes, totalBytes, totalFreeBytes: TFiletime - discard getDiskFreeSpaceEx(r"C:\", freeBytes, totalBytes, - totalFreeBytes) - return (freeBytes, totalBytes) - -when isMainModule: - var r = getMemoryInfo() - echo("Memory load: ", r.MemoryLoad, "%") - - var osvi = getVersionInfo() - - echo($osvi) - - echo(getFileSize(r"lib\impure\osinfo_win.nim") div 1024, " KB") - - echo(rdFileTime(getPartitionInfo(r"C:\")[0])) +# +# +# Nim's Runtime Library +# (c) Copyright 2015 Dominik Picheta +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +{.error: "This module has been moved to the 'osinfo' nimble package.".} diff --git a/lib/pure/fenv.nim b/lib/pure/fenv.nim index 6f9085c92..fd0eab310 100644 --- a/lib/pure/fenv.nim +++ b/lib/pure/fenv.nim @@ -101,3 +101,81 @@ proc feupdateenv*(envp: ptr Tfenv): cint {.importc, header: "<fenv.h>".} ## Save current exceptions in temporary storage, install environment ## represented by object pointed to by `envp` and raise exceptions ## according to saved exceptions. + +var FP_RADIX_INTERNAL {. importc: "FLT_RADIX" header: "<float.h>" .} : int + +template fpRadix* : int = FLT_RADIX_INTERNAL + ## The (integer) value of the radix used to represent any floating + ## point type on the architecture used to build the program. + +var FLT_MANT_DIG {. importc: "FLT_MANT_DIG" header: "<float.h>" .} : int +var FLT_DIG {. importc: "FLT_DIG" header: "<float.h>" .} : int +var FLT_MIN_EXP {. importc: "FLT_MIN_EXP" header: "<float.h>" .} : int +var FLT_MAX_EXP {. importc: "FLT_MAX_EXP" header: "<float.h>" .} : int +var FLT_MIN_10_EXP {. importc: "FLT_MIN_10_EXP" header: "<float.h>" .} : int +var FLT_MAX_10_EXP {. importc: "FLT_MAX_10_EXP" header: "<float.h>" .} : int +var FLT_MIN {. importc: "FLT_MIN" header: "<float.h>" .} : cfloat +var FLT_MAX {. importc: "FLT_MAX" header: "<float.h>" .} : cfloat +var FLT_EPSILON {. importc: "FLT_EPSILON" header: "<float.h>" .} : cfloat + +var DBL_MANT_DIG {. importc: "DBL_MANT_DIG" header: "<float.h>" .} : int +var DBL_DIG {. importc: "DBL_DIG" header: "<float.h>" .} : int +var DBL_MIN_EXP {. importc: "DBL_MIN_EXP" header: "<float.h>" .} : int +var DBL_MAX_EXP {. importc: "DBL_MAX_EXP" header: "<float.h>" .} : int +var DBL_MIN_10_EXP {. importc: "DBL_MIN_10_EXP" header: "<float.h>" .} : int +var DBL_MAX_10_EXP {. importc: "DBL_MAX_10_EXP" header: "<float.h>" .} : int +var DBL_MIN {. importc: "DBL_MIN" header: "<float.h>" .} : cdouble +var DBL_MAX {. importc: "DBL_MAX" header: "<float.h>" .} : cdouble +var DBL_EPSILON {. importc: "DBL_EPSILON" header: "<float.h>" .} : cdouble + +template mantissaDigits*(T : typedesc[float32]) : int = FLT_MANT_DIG + ## Number of digits (in base ``floatingPointRadix``) in the mantissa + ## of 32-bit floating-point numbers. +template digits*(T : typedesc[float32]) : int = FLT_DIG + ## Number of decimal digits that can be represented in a + ## 32-bit floating-point type without losing precision. +template minExponent*(T : typedesc[float32]) : int = FLT_MIN_EXP + ## Minimum (negative) exponent for 32-bit floating-point numbers. +template maxExponent*(T : typedesc[float32]) : int = FLT_MAX_EXP + ## Maximum (positive) exponent for 32-bit floating-point numbers. +template min10Exponent*(T : typedesc[float32]) : int = FLT_MIN_10_EXP + ## Minimum (negative) exponent in base 10 for 32-bit floating-point + ## numbers. +template max10Exponent*(T : typedesc[float32]) : int = FLT_MAX_10_EXP + ## Maximum (positive) exponent in base 10 for 32-bit floating-point + ## numbers. +template minimumPositiveValue*(T : typedesc[float32]) : float32 = FLT_MIN + ## The smallest positive (nonzero) number that can be represented in a + ## 32-bit floating-point type. +template maximumPositiveValue*(T : typedesc[float32]) : float32 = FLT_MAX + ## The largest positive number that can be represented in a 32-bit + ## floating-point type. +template epsilon*(T : typedesc[float32]): float32 = FLT_EPSILON + ## The difference between 1.0 and the smallest number greater than + ## 1.0 that can be represented in a 32-bit floating-point type. + +template mantissaDigits*(T : typedesc[float64]) : int = DBL_MANT_DIG + ## Number of digits (in base ``floatingPointRadix``) in the mantissa + ## of 64-bit floating-point numbers. +template digits*(T : typedesc[float64]) : int = DBL_DIG + ## Number of decimal digits that can be represented in a + ## 64-bit floating-point type without losing precision. +template minExponent*(T : typedesc[float64]) : int = DBL_MIN_EXP + ## Minimum (negative) exponent for 64-bit floating-point numbers. +template maxExponent*(T : typedesc[float64]) : int = DBL_MAX_EXP + ## Maximum (positive) exponent for 64-bit floating-point numbers. +template min10Exponent*(T : typedesc[float64]) : int = DBL_MIN_10_EXP + ## Minimum (negative) exponent in base 10 for 64-bit floating-point + ## numbers. +template max10Exponent*(T : typedesc[float64]) : int = DBL_MAX_10_EXP + ## Maximum (positive) exponent in base 10 for 64-bit floating-point + ## numbers. +template minimumPositiveValue*(T : typedesc[float64]) : float64 = DBL_MIN + ## The smallest positive (nonzero) number that can be represented in a + ## 64-bit floating-point type. +template maximumPositiveValue*(T : typedesc[float64]) : float64 = DBL_MAX + ## The largest positive number that can be represented in a 64-bit + ## floating-point type. +template epsilon*(T : typedesc[float64]): float64 = DBL_EPSILON + ## The difference between 1.0 and the smallest number greater than + ## 1.0 that can be represented in a 64-bit floating-point type. diff --git a/lib/pure/logging.nim b/lib/pure/logging.nim index b64437c89..16c36e1f0 100644 --- a/lib/pure/logging.nim +++ b/lib/pure/logging.nim @@ -217,7 +217,7 @@ method log*(logger: RollingFileLogger, level: Level, logger.curLine = 0 logger.f = open(logger.baseName, logger.baseMode) - writeln(logger.f, LevelNames[level], " ", frmt % args) + writeln(logger.f, LevelNames[level], " ",substituteLog(logger.fmtStr), frmt % args) logger.curLine.inc # -------- diff --git a/lib/pure/md5.nim b/lib/pure/md5.nim index c6228af50..5ee301b15 100644 --- a/lib/pure/md5.nim +++ b/lib/pure/md5.nim @@ -213,13 +213,13 @@ proc toMD5*(s: string): MD5Digest = md5Update(c, cstring(s), len(s)) md5Final(c, result) -proc `$`*(D: MD5Digest): string = +proc `$`*(d: MD5Digest): string = ## converts a MD5Digest value into its string representation const digits = "0123456789abcdef" result = "" for i in 0..15: - add(result, digits[(D[i] shr 4) and 0xF]) - add(result, digits[D[i] and 0xF]) + add(result, digits[(d[i] shr 4) and 0xF]) + add(result, digits[d[i] and 0xF]) proc getMD5*(s: string): string = ## computes an MD5 value of `s` and returns its string representation diff --git a/lib/pure/redis.nim b/lib/pure/redis.nim index 64d3e1470..9177ddee5 100644 --- a/lib/pure/redis.nim +++ b/lib/pure/redis.nim @@ -285,6 +285,30 @@ proc keys*(r: Redis, pattern: string): RedisList = r.sendCommand("KEYS", pattern) return r.readArray() +proc scan*(r: Redis, cursor: var BiggestInt): RedisList = + ## Find all keys matching the given pattern and yield it to client in portions + ## using default Redis values for MATCH and COUNT parameters + r.sendCommand("SCAN", $cursor) + let reply = r.readArray() + cursor = strutils.parseBiggestInt(reply[0]) + return reply[1..high(reply)] + +proc scan*(r: Redis, cursor: var BiggestInt, pattern: string): RedisList = + ## Find all keys matching the given pattern and yield it to client in portions + ## using cursor as a client query identifier. Using default Redis value for COUNT argument + r.sendCommand("SCAN", $cursor, ["MATCH", pattern]) + let reply = r.readArray() + cursor = strutils.parseBiggestInt(reply[0]) + return reply[1..high(reply)] + +proc scan*(r: Redis, cursor: var BiggestInt, pattern: string, count: int): RedisList = + ## Find all keys matching the given pattern and yield it to client in portions + ## using cursor as a client query identifier. + r.sendCommand("SCAN", $cursor, ["MATCH", pattern, "COUNT", $count]) + let reply = r.readArray() + cursor = strutils.parseBiggestInt(reply[0]) + return reply[1..high(reply)] + proc move*(r: Redis, key: string, db: int): bool = ## Move a key to another database. Returns `true` on a successful move. r.sendCommand("MOVE", key, $db) diff --git a/lib/pure/times.nim b/lib/pure/times.nim index c39667611..25f6b85f6 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -26,9 +26,10 @@ type WeekDay* = enum ## represents a weekday dMon, dTue, dWed, dThu, dFri, dSat, dSun -var - timezone {.importc, header: "<time.h>".}: int - tzname {.importc, header: "<time.h>" .}: array[0..1, cstring] +when not defined(JS): + var + timezone {.importc, header: "<time.h>".}: int + tzname {.importc, header: "<time.h>" .}: array[0..1, cstring] when defined(posix) and not defined(JS): type @@ -48,6 +49,11 @@ when defined(posix) and not defined(JS): proc posix_gettimeofday(tp: var Timeval, unused: pointer = nil) {. importc: "gettimeofday", header: "<sys/time.h>".} + # we also need tzset() to make sure that tzname is initialized + proc tzset() {.importc, header: "<sys/time.h>".} + # calling tzset() implicitly to initialize tzname data. + tzset() + elif defined(windows): import winlean @@ -482,7 +488,7 @@ elif defined(JS): return newDate() const - weekDays: array [0..6, TWeekDay] = [ + weekDays: array [0..6, WeekDay] = [ dSun, dMon, dTue, dWed, dThu, dFri, dSat] proc getLocalTime(t: Time): TimeInfo = @@ -490,7 +496,7 @@ elif defined(JS): result.minute = t.getMinutes() result.hour = t.getHours() result.monthday = t.getDate() - result.month = TMonth(t.getMonth()) + result.month = Month(t.getMonth()) result.year = t.getFullYear() result.weekday = weekDays[t.getDay()] result.yearday = 0 @@ -500,7 +506,7 @@ elif defined(JS): result.minute = t.getUTCMinutes() result.hour = t.getUTCHours() result.monthday = t.getUTCDate() - result.month = TMonth(t.getUTCMonth()) + result.month = Month(t.getUTCMonth()) result.year = t.getUTCFullYear() result.weekday = weekDays[t.getUTCDay()] result.yearday = 0 @@ -554,7 +560,7 @@ proc `$`*(day: WeekDay): string = return lookup[day] proc `$`*(m: Month): string = - ## stingify operator for ``TMonth``. + ## stingify operator for ``Month``. const lookup: array[Month, string] = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] @@ -1104,4 +1110,4 @@ when isMainModule: # Kitchen = "3:04PM" s = "3:04PM" f = "h:mmtt" - echo "Kitchen: " & $s.parse(f) \ No newline at end of file + echo "Kitchen: " & $s.parse(f) diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index 48adb895d..468af1713 100644 --- a/lib/system/sysio.nim +++ b/lib/system/sysio.nim @@ -154,7 +154,7 @@ proc readAll(file: File): TaintedString = proc readFile(filename: string): TaintedString = var f = open(filename) try: - result = readAllFile(f).TaintedString + result = readAll(f).TaintedString finally: close(f) diff --git a/lib/wrappers/openssl.nim b/lib/wrappers/openssl.nim index bca7b3a40..03729dbab 100644 --- a/lib/wrappers/openssl.nim +++ b/lib/wrappers/openssl.nim @@ -298,7 +298,7 @@ when not useWinVersion: if p != nil: dealloc(p) proc CRYPTO_malloc_init*() = - when not useWinVersion: + when not useWinVersion and not defined(macosx): CRYPTO_set_mem_functions(allocWrapper, reallocWrapper, deallocWrapper) proc SSL_CTX_ctrl*(ctx: SslCtx, cmd: cInt, larg: int, parg: pointer): int{. diff --git a/tests/objects/tobjconstr.nim b/tests/objects/tobjconstr.nim index 3bd785728..226fe98f7 100644 --- a/tests/objects/tobjconstr.nim +++ b/tests/objects/tobjconstr.nim @@ -1,14 +1,14 @@ discard """ - output: '''(k: kindA, a: (x: abc, z: [1, 1, 3]), empty: ()) -(k: kindA, a: (x: abc, z: [1, 2, 3]), empty: ()) -(k: kindA, a: (x: abc, z: [1, 3, 3]), empty: ()) -(k: kindA, a: (x: abc, z: [1, 4, 3]), empty: ()) -(k: kindA, a: (x: abc, z: [1, 5, 3]), empty: ()) -(k: kindA, a: (x: abc, z: [1, 6, 3]), empty: ()) -(k: kindA, a: (x: abc, z: [1, 7, 3]), empty: ()) -(k: kindA, a: (x: abc, z: [1, 8, 3]), empty: ()) -(k: kindA, a: (x: abc, z: [1, 9, 3]), empty: ()) -(k: kindA, a: (x: abc, z: [1, 10, 3]), empty: ())''' + output: '''(k: kindA, a: (x: abc, z: [1, 1, 3]), method: ()) +(k: kindA, a: (x: abc, z: [1, 2, 3]), method: ()) +(k: kindA, a: (x: abc, z: [1, 3, 3]), method: ()) +(k: kindA, a: (x: abc, z: [1, 4, 3]), method: ()) +(k: kindA, a: (x: abc, z: [1, 5, 3]), method: ()) +(k: kindA, a: (x: abc, z: [1, 6, 3]), method: ()) +(k: kindA, a: (x: abc, z: [1, 7, 3]), method: ()) +(k: kindA, a: (x: abc, z: [1, 8, 3]), method: ()) +(k: kindA, a: (x: abc, z: [1, 9, 3]), method: ()) +(k: kindA, a: (x: abc, z: [1, 10, 3]), method: ())''' """ type @@ -20,9 +20,9 @@ type TDummy = ref object case k: TKind of kindXY: x, y: int - of kindA: + of kindA: a: TArg - empty: TEmpty + `method`: TEmpty # bug #1791 proc `$`[T](s: seq[T]): string = # XXX why is that not in the stdlib? @@ -34,7 +34,7 @@ proc `$`[T](s: seq[T]): string = proc main() = for i in 1..10: - let d = TDummy(k: kindA, a: TArg(x: "abc", z: @[1,i,3]), empty: TEmpty()) + let d = TDummy(k: kindA, a: TArg(x: "abc", z: @[1,i,3]), `method`: TEmpty()) echo d[] main() diff --git a/todo.txt b/todo.txt index 47180aaf1..b77c276b7 100644 --- a/todo.txt +++ b/todo.txt @@ -3,8 +3,6 @@ version 0.10.4 - improve GC-unsafety warnings - make 'nil' work for 'add' and 'len' -- get rid of 'mget'; aka priority of 'var' needs to be 'var{lvalue}' -- 'result' shadowing warning - disallow negative indexing - improve the parser; deal with echo $foo gotcha @@ -60,9 +58,9 @@ Bugs version 0.9.x ============= +- pragmas need 'bindSym' support - allow simple read accesses to global variables --> difficult to ensure that no data races happen -- pragmas need 'bindSym' support - pragmas need re-work: 'push' is dangerous, 'hasPragma' does not work reliably with user-defined pragmas - memory manager: add a measure of fragmentation @@ -77,7 +75,6 @@ version 0.9.X ============= - macros as type pragmas -- document how lazy overloading resolution works - document NimMain and check whether it works for threading GC diff --git a/web/news.txt b/web/news.txt index aa093be46..7cf1ae28f 100644 --- a/web/news.txt +++ b/web/news.txt @@ -3,8 +3,8 @@ News ==== .. - 2015-03-01 Version 1.0.0 released - ================================= + 2015-03-01 Version 0.10.4 released + ================================== Changes affecting backwards compatibility @@ -23,7 +23,7 @@ News - *arrow like* operators are not right associative anymore. - Typeless parameters are now only allowed in templates and macros. The old way turned out to be too error-prone. - + Language Additions ------------------ @@ -46,14 +46,230 @@ News - Ordinary parameters can follow after a varargs parameter. This means the following is finally accepted by the compiler: - .. code-block:: nim + .. code-block:: nim template takesBlock(a, b: int, x: varargs[expr]; blck: stmt) = blck echo a, b takesBlock 1, 2, "some", 0.90, "random stuff": echo "yay" - + + - Overloading by 'var T' is now finally possible: + + .. code-block:: nim + proc varOrConst(x: var int) = echo "var" + proc varOrConst(x: int) = echo "const" + + var x: int + varOrConst(x) # "var" + varOrConst(45) # "const" + + + Library additions + ----------------- + + - ``reversed`` proc added to the ``unicode`` module. + - Added multipart param to httpclient's ``post`` and ``postContent`` together + with a ``newMultipartData`` proc. + - Added `%*` operator for JSON. + - The compiler is now available as Nimble package for c2nim. + + + Bugfixes + -------- + + - Fixed internal compiler error when using ``char()`` in an echo call + (`#1788 <https://github.com/Araq/Nim/issues/1788>`_). + - Fixed Windows cross-compilation on Linux. + - Overload resolution now works for types distinguished only by a + ``static[int]`` param + (`#1056 <https://github.com/Araq/Nim/issues/1056>`_). + - Other fixes relating to generic types and static params. + - Fixed some compiler crashes with unnamed tuples + (`#1774 <https://github.com/Araq/Nim/issues/1774>`_). + - Fixed ``channels.tryRecv`` blocking + (`#1816 <https://github.com/Araq/Nim/issues/1816>`_). + - Fixed generic instantiation errors with ``typedesc`` + (`#419 <https://github.com/Araq/Nim/issues/419>`_). + - Fixed generic regression where the compiler no longer detected constant + expressions properly (`#544 <https://github.com/Araq/Nim/issues/544>`_). + - Fixed internal error with generic proc using ``static[T]`` in a specific + way (`#1049 <https://github.com/Araq/Nim/issues/1049>`_). + - More fixes relating to generics + (`#1820 <https://github.com/Araq/Nim/issues/1820>`_, + `#1050 <https://github.com/Araq/Nim/issues/1050>`_, + `#1859 <https://github.com/Araq/Nim/issues/1859>`_, + `#1858 <https://github.com/Araq/Nim/issues/1858>`_). + - Fixed httpclient to properly encode queries. + - Many fixes to the ``uri`` module. + - Async sockets are now closed on error. + - Fixes to httpclient's handling of multipart data. + - Fixed GC segfaults with asynchronous sockets + (`#1796 <https://github.com/Araq/Nim/issues/1796>`_). + - Added more versions to openssl's DLL version list + (`076f993 <https://github.com/Araq/Nim/commit/076f993>`_). + - Fixed shallow copy in iterators being broken + (`#1803 <https://github.com/Araq/Nim/issues/1803>`_). + - ``nil`` can now be inserted into tables with the ``db_sqlite`` module + (`#1866 <https://github.com/Araq/Nim/issues/1866>`_). + - Fixed "Incorrect assembler generated" + (`#1907 <https://github.com/Araq/Nim/issues/1907>`_) + - Fixed "Expression templates that define macros are unusable in some contexts" + (`#1903 <https://github.com/Araq/Nim/issues/1903>`_) + - Fixed "a second level generic subclass causes the compiler to crash" + (`#1919 <https://github.com/Araq/Nim/issues/1919>`_) + - Fixed "nim 0.10.2 generates invalid AsyncHttpClient C code for MSVC " + (`#1901 <https://github.com/Araq/Nim/issues/1901>`_) + - Fixed "1 shl n produces wrong C code" + (`#1928 <https://github.com/Araq/Nim/issues/1928>`_) + - Fixed "Internal error on tuple yield" + (`#1838 <https://github.com/Araq/Nim/issues/1838>`_) + - Fixed "ICE with template" + (`#1915 <https://github.com/Araq/Nim/issues/1915>`_) + - Fixed "include the tool directory in the installer as it is required by koch" + (`#1947 <https://github.com/Araq/Nim/issues/1947>`_) + - Fixed "Can't compile if file location contains spaces on Windows" + (`#1955 <https://github.com/Araq/Nim/issues/1955>`_) + - Fixed "List comprehension macro only supports infix checks as guards" + (`#1920 <https://github.com/Araq/Nim/issues/1920>`_) + - Fixed "wrong field names of compatible tuples in generic types" + (`#1910 <https://github.com/Araq/Nim/issues/1910>`_) + - Fixed "Macros within templates no longer work as expected" + (`#1944 <https://github.com/Araq/Nim/issues/1944>`_) + - Fixed "Compiling for Standalone AVR broken in 0.10.2" + (`#1964 <https://github.com/Araq/Nim/issues/1964>`_) + - Fixed "Compiling for Standalone AVR broken in 0.10.2" + (`#1964 <https://github.com/Araq/Nim/issues/1964>`_) + - Fixed "Code generation for mitems with tuple elements" + (`#1833 <https://github.com/Araq/Nim/issues/1833>`_) + - Fixed "httpclient.HttpMethod should not be an enum" + (`#1962 <https://github.com/Araq/Nim/issues/1962>`_) + - Fixed "terminal / eraseScreen() throws an OverflowError" + (`#1906 <https://github.com/Araq/Nim/issues/1906>`_) + - Fixed "setControlCHook(nil) disables registered quit procs" + (`#1546 <https://github.com/Araq/Nim/issues/1546>`_) + - Fixed "Unexpected idetools behaviour" + (`#325 <https://github.com/Araq/Nim/issues/325>`_) + - Fixed "Unused lifted lambda does not compile" + (`#1642 <https://github.com/Araq/Nim/issues/1642>`_) + - Fixed "'low' and 'high' don't work with cstring asguments" + (`#2030 <https://github.com/Araq/Nim/issues/2030>`_) + - Fixed "Converting to int does not round in JS backend" + (`#1959 <https://github.com/Araq/Nim/issues/1959>`_) + - Fixed "Internal error genRecordField 2 when adding region to pointer." + (`#2039 <https://github.com/Araq/Nim/issues/2039>`_) + - Fixed "Macros fail to compile when compiled with --os:standalone" + (`#2041 <https://github.com/Araq/Nim/issues/2041>`_) + - Fixed "Reading from {.compileTime.} variables can cause code generation to fail" + (`#2022 <https://github.com/Araq/Nim/issues/2022>`_) + - Fixed "Passing overloaded symbols to templates fails inside generic procedures" + (`#1988 <https://github.com/Araq/Nim/issues/1988>`_) + - Fixed "Compiling iterator with object assignment in release mode causes "var not init"" + (`#2023 <https://github.com/Araq/Nim/issues/2023>`_) + - Fixed "calling a large number of macros doing some computation fails" + (`#1989 <https://github.com/Araq/Nim/issues/1989>`_) + - Fixed "Can't get Koch to install nim under Windows" + (`#2061 <https://github.com/Araq/Nim/issues/2061>`_) + - Fixed "Template with two stmt parameters segfaults compiler" + (`#2057 <https://github.com/Araq/Nim/issues/2057>`_) + - Fixed "`noSideEffect` not affected by `echo`" + (`#2011 <https://github.com/Araq/Nim/issues/2011>`_) + - Fixed "Compiling with the cpp backend ignores --passc" + (`#1601 <https://github.com/Araq/Nim/issues/1601>`_) + - Fixed "Put untyped procedure parameters behind the experimental pragma" + (`#1956 <https://github.com/Araq/Nim/issues/1956>`_) + - Fixed "generic regression" + (`#2073 <https://github.com/Araq/Nim/issues/2073>`_) + - Fixed "generic regression" + (`#2073 <https://github.com/Araq/Nim/issues/2073>`_) + - Fixed "Regression in template lookup with generics" + (`#2004 <https://github.com/Araq/Nim/issues/2004>`_) + - Fixed "GC's growObj is wrong for edge cases" + (`#2070 <https://github.com/Araq/Nim/issues/2070>`_) + - Fixed "Compiler internal error when creating an array out of a typeclass" + (`#1131 <https://github.com/Araq/Nim/issues/1131>`_) + - Fixed "GC's growObj is wrong for edge cases" + (`#2070 <https://github.com/Araq/Nim/issues/2070>`_) + - Fixed "Invalid Objective-C code generated when calling class method" + (`#2068 <https://github.com/Araq/Nim/issues/2068>`_) + - Fixed "walkDirRec Error" + (`#2116 <https://github.com/Araq/Nim/issues/2116>`_) + - Fixed "Typo in code causes compiler SIGSEGV in evalAtCompileTime" + (`#2113 <https://github.com/Araq/Nim/issues/2113>`_) + - Fixed "Regression on exportc" + (`#2118 <https://github.com/Araq/Nim/issues/2118>`_) + - Fixed "Error message" + (`#2102 <https://github.com/Araq/Nim/issues/2102>`_) + - Fixed "hint[path] = off not working in nim.cfg" + (`#2103 <https://github.com/Araq/Nim/issues/2103>`_) + - Fixed "compiler crashes when getting a tuple from a sequence of generic tuples" + (`#2121 <https://github.com/Araq/Nim/issues/2121>`_) + - Fixed "nim check hangs with when" + (`#2123 <https://github.com/Araq/Nim/issues/2123>`_) + - Fixed "static[T] param in nested type resolve/caching issue" + (`#2125 <https://github.com/Araq/Nim/issues/2125>`_) + - Fixed "repr should display ``\0``" + (`#2124 <https://github.com/Araq/Nim/issues/2124>`_) + - Fixed "'nim check' never ends in case of recursive dependency " + (`#2051 <https://github.com/Araq/Nim/issues/2051>`_) + - Fixed "From macros: Error: unhandled exception: sons is not accessible" + (`#2167 <https://github.com/Araq/Nim/issues/2167>`_) + - Fixed "`fieldPairs` doesn't work inside templates" + (`#1902 <https://github.com/Araq/Nim/issues/1902>`_) + - Fixed "fields iterator misbehavior on break statement" + (`#2134 <https://github.com/Araq/Nim/issues/2134>`_) + - Fixed "Fix for compiler not building anymore since #c3244ef1ff" + (`#2193 <https://github.com/Araq/Nim/issues/2193>`_) + - Fixed "JSON parser fails in cpp output mode" + (`#2199 <https://github.com/Araq/Nim/issues/2199>`_) + - Fixed "macros.getType mishandles void return" + (`#2211 <https://github.com/Araq/Nim/issues/2211>`_) + - Fixed "Regression involving templates instantiated within generics" + (`#2215 <https://github.com/Araq/Nim/issues/2215>`_) + - Fixed ""Error: invalid type" for 'not nil' on generic type." + (`#2216 <https://github.com/Araq/Nim/issues/2216>`_) + - Fixed "--threads:on breaks async" + (`#2074 <https://github.com/Araq/Nim/issues/2074>`_) + - Fixed "Type mismatch not always caught, can generate bad code for C backend." + (`#2169 <https://github.com/Araq/Nim/issues/2169>`_) + - Fixed "Failed C compilation when storing proc to own type in object" + (`#2233 <https://github.com/Araq/Nim/issues/2233>`_) + - Fixed "Unknown line/column number in constant declaration type conversion error" + (`#2252 <https://github.com/Araq/Nim/issues/2252>`_) + - Fixed "Adding {.compile.} fails if nimcache already exists." + (`#2247 <https://github.com/Araq/Nim/issues/2247>`_) + - Fixed "Two different type names generated for a single type (C backend)" + (`#2250 <https://github.com/Araq/Nim/issues/2250>`_) + - Fixed "Ambigous call when it should not be" + (`#2229 <https://github.com/Araq/Nim/issues/2229>`_) + - Fixed "Make sure we can load root urls" + (`#2227 <https://github.com/Araq/Nim/issues/2227>`_) + - Fixed "Failure to slice a string with an int subrange type" + (`#794 <https://github.com/Araq/Nim/issues/794>`_) + - Fixed "documentation error" + (`#2205 <https://github.com/Araq/Nim/issues/2205>`_) + - Fixed "Code growth when using `const`" + (`#1940 <https://github.com/Araq/Nim/issues/1940>`_) + - Fixed "Instances of generic types confuse overload resolution" + (`#2220 <https://github.com/Araq/Nim/issues/2220>`_) + - Fixed "Compiler error when initializing sdl2's EventType" + (`#2316 <https://github.com/Araq/Nim/issues/2316>`_) + - Fixed "Parallel disjoint checking can't handle `<`, `items`, or arrays" + (`#2287 <https://github.com/Araq/Nim/issues/2287>`_) + - Fixed "Strings aren't copied in parallel loop" + (`#2286 <https://github.com/Araq/Nim/issues/2286>`_) + - Fixed "JavaScript compiler crash with tables" + (`#2298 <https://github.com/Araq/Nim/issues/2298>`_) + - Fixed "Range checker too restrictive" + (`#1845 <https://github.com/Araq/Nim/issues/1845>`_) + - Fixed "Failure to slice a string with an int subrange type" + (`#794 <https://github.com/Araq/Nim/issues/794>`_) + - Fixed "Remind user when compiling in debug mode" + (`#1868 <https://github.com/Araq/Nim/issues/1868>`_) + - Fixed "Compiler user guide has jumbled options/commands." + (`#1819 <https://github.com/Araq/Nim/issues/1819>`_) + - Fixed "using `method`: 1 in a objects constructor fails when compiling" + (`#1791 <https://github.com/Araq/Nim/issues/1791>`_) 2014-12-29 Version 0.10.2 released ================================== @@ -253,8 +469,8 @@ Bugfixes 2014-12-09 New website design! ============================== -A brand new website including an improved forum is now live. -All thanks go to Philip Witte and +A brand new website including an improved forum is now live. +All thanks go to Philip Witte and Dominik Picheta, Philip Witte for the design of the website (together with the logo) as well as the HTML and CSS code for his template, and Dominik Picheta for integrating Philip's design with Nim's forum. We're sure you will @@ -321,7 +537,7 @@ Library Additions - ``sequtils.distnct`` has been renamed to ``sequtils.deduplicate``. - Added ``algorithm.reversed`` - Added ``uri.combine`` and ``uri.parseUri``. -- Some sockets procedures now support a ``SafeDisconn`` flag which causes +- Some sockets procedures now support a ``SafeDisconn`` flag which causes them to handle disconnection errors and not raise them. @@ -336,7 +552,7 @@ unfortunately some do not fulfill our quality standards yet.** Prebuilt binaries and instructions for building from source are available on the `download page <download.html>`_. -This release includes about +This release includes about `1400 changes <https://github.com/Araq/Nimrod/compare/v0.9.2...v0.9.4>`_ in total including various bug fixes, new languages features and standard library additions and improvements. @@ -395,10 +611,10 @@ Note that this feature has been implemented with Nimrod's macro system and so Syntactic sugar for anonymous procedures has also been introduced. It too has been implemented as a macro. The following shows some simple usage of the new syntax: - + .. code-block::nim import future - + var s = @[1, 2, 3, 4, 5] echo(s.map((x: int) => x * 5)) @@ -425,14 +641,14 @@ Library Additions Changes affecting backwards compatibility ----------------------------------------- -- The scoping rules for the ``if`` statement changed for better interaction +- The scoping rules for the ``if`` statement changed for better interaction with the new syntactic construct ``(;)``. - ``OSError`` family of procedures has been deprecated. Procedures with the same name but which take different parameters have been introduced. These procs now require an error code to be passed to them. This error code can be retrieved using the new ``OSLastError`` proc. - ``os.parentDir`` now returns "" if there is no parent dir. -- In CGI scripts stacktraces are shown to the user only +- In CGI scripts stacktraces are shown to the user only if ``cgi.setStackTraceStdout`` is used. - The symbol binding rules for clean templates changed: ``bind`` for any symbol that's not a parameter is now the default. ``mixin`` can be used @@ -466,7 +682,7 @@ Compiler Additions evaluation. - ``--gc:none`` produces warnings when code uses the GC. - A ``union`` pragma for better C interoperability is now supported. -- A ``packed`` pragma to control the memory packing/alignment of fields in +- A ``packed`` pragma to control the memory packing/alignment of fields in an object. - Arrays can be annotated to be ``unchecked`` for easier low level manipulations of memory. @@ -515,13 +731,13 @@ as the cover story in the February 2014 issue of Dr. Dobb's Journal. Andreas Rumpf presented *Nimrod: A New Approach to Metaprogramming* at `Strange Loop 2013<https://thestrangeloop.com/sessions/nimrod-a-new-approach-to-meta-programming>`_. The `video and slides<http://www.infoq.com/presentations/nimrod>`_ -of the talk are now available. +of the talk are now available. 2013-05-20 New website design! ============================== -A brand new website is now live. All thanks go to Philip Witte and +A brand new website is now live. All thanks go to Philip Witte and Dominik Picheta, Philip Witte for the design of the website (together with the logo) as well as the HTML and CSS code for his template, and Dominik Picheta for integrating Philip's design with the ``nimweb`` utility. We're sure you will @@ -537,7 +753,7 @@ to any other release. This release brings with it many new features and bug fixes, a list of which can be seen later. One of the major new features is the effect system together -with exception tracking which allows for checked exceptions and more, +with exception tracking which allows for checked exceptions and more, for further details check out the `manual <manual.html#effect-system>`_. Another major new feature is the introduction of statement list expressions, more details on these can be found `here <manual.html#statement-list-expression>`_. @@ -550,12 +766,12 @@ Bugfixes -------- - The old GC never collected cycles correctly. Fixed but it can cause - performance regressions. However you can deactivate the cycle collector - with ``GC_disableMarkAndSweep`` and run it explicitly at an appropriate time - or not at all. There is also a new GC you can activate + performance regressions. However you can deactivate the cycle collector + with ``GC_disableMarkAndSweep`` and run it explicitly at an appropriate time + or not at all. There is also a new GC you can activate with ``--gc:markAndSweep`` which does not have this problem but is slower in general and has no realtime guarantees. -- ``cast`` for floating point types now does the bitcast as specified in the +- ``cast`` for floating point types now does the bitcast as specified in the manual. This breaks code that erroneously uses ``cast`` to convert different floating point values. - SCGI module's performance has been improved greatly, it will no longer block @@ -566,7 +782,7 @@ Bugfixes Library Additions ----------------- -- There is a new experimental mark&sweep GC which can be faster (or much +- There is a new experimental mark&sweep GC which can be faster (or much slower) than the default GC. Enable with ``--gc:markAndSweep``. - Added ``system.onRaise`` to support a condition system. - Added ``system.locals`` that provides access to a proc's locals. @@ -603,41 +819,41 @@ Compiler Additions to be turned on explicitly via ``--warning[ShadowIdent]:on``. - The compiler now supports almost every pragma in a ``push`` pragma. - Generic converters have been implemented. -- Added a **highly experimental** ``noforward`` pragma enabling a special +- Added a **highly experimental** ``noforward`` pragma enabling a special compilation mode that largely eliminates the need for forward declarations. Language Additions ------------------ - ``case expressions`` are now supported. -- Table constructors now mimic more closely the syntax of the ``case`` +- Table constructors now mimic more closely the syntax of the ``case`` statement. - Nimrod can now infer the return type of a proc from its body. - Added a ``mixin`` declaration to affect symbol binding rules in generics. - Exception tracking has been added and the ``doc2`` command annotates possible exceptions for you. -- User defined effects ("tags") tracking has been added and the ``doc2`` +- User defined effects ("tags") tracking has been added and the ``doc2`` command annotates possible tags for you. - Types can be annotated with the new syntax ``not nil`` to explicitly state that ``nil`` is not allowed. However currently the compiler performs no advanced static checking for this; for now it's merely for documentation purposes. - An ``export`` statement has been added to the language: It can be used for - symbol forwarding so client modules don't have to import a module's + symbol forwarding so client modules don't have to import a module's dependencies explicitly. - Overloading based on ASTs has been implemented. - Generics are now supported for multi methods. - Objects can be initialized via an *object constructor expression*. -- There is a new syntactic construct ``(;)`` unifying expressions and +- There is a new syntactic construct ``(;)`` unifying expressions and statements. - You can now use ``from module import nil`` if you want to import the module but want to enforce fully qualified access to every symbol in ``module``. - + Notes for the future -------------------- -- The scope rules of ``if`` statements will change in 0.9.4. This affects the +- The scope rules of ``if`` statements will change in 0.9.4. This affects the ``=~`` pegs/re templates. - The ``sockets`` module will become a low-level wrapper of OS-specific socket functions. All the high-level features of the current ``sockets`` module @@ -681,14 +897,14 @@ Library Additions assignments. - Added ``system.eval`` that can execute an anonymous block of code at compile time as if was a macro. -- Added ``system.staticExec`` and ``system.gorge`` for compile-time execution +- Added ``system.staticExec`` and ``system.gorge`` for compile-time execution of external programs. - Added ``system.staticRead`` as a synonym for ``system.slurp``. - Added ``macros.emit`` that can emit an arbitrary computed string as nimrod code during compilation. - Added ``strutils.parseEnum``. - Added ``json.%`` constructor operator. -- The stdlib can now be avoided to a point where C code generation for 16bit +- The stdlib can now be avoided to a point where C code generation for 16bit micro controllers is feasible. - Added module ``oids``. - Added module ``endians``. @@ -704,7 +920,7 @@ Library Additions - Added ``strutils.continuesWith``. - Added ``system.getStackTrace``. - Added ``system.||`` for parallel ``for`` loop support. -- The GC supports (soft) realtime systems via ``GC_setMaxPause`` +- The GC supports (soft) realtime systems via ``GC_setMaxPause`` and ``GC_step`` procs. - The sockets module now supports ssl through the OpenSSL library, ``recvLine`` is now much more efficient thanks to the newly implemented sockets buffering. @@ -715,14 +931,14 @@ Library Additions only support fixed length arrays). - Added ``system.compiles`` which can be used to check whether a type supports some operation. -- Added ``strutils.format``, ``subexes.format`` which use the +- Added ``strutils.format``, ``subexes.format`` which use the new ``varargs`` type. - Added module ``fsmonitor``. Changes affecting backwards compatibility ----------------------------------------- -- On Windows filenames and paths are supposed to be in UTF-8. +- On Windows filenames and paths are supposed to be in UTF-8. The ``system``, ``os``, ``osproc`` and ``memfiles`` modules use the wide string versions of the WinAPI. Use the ``-d:useWinAnsi`` switch to revert back to the old behaviour which uses the Ansi string versions. @@ -747,21 +963,21 @@ Changes affecting backwards compatibility - Deprecated ``nimrod pretty`` as it never worked good enough and has some inherent problems. - The integer promotion rules changed; the compiler is now less picky in some - situations and more picky in other situations: In particular implicit + situations and more picky in other situations: In particular implicit conversions from ``int`` to ``int32`` are now forbidden. -- ``system.byte`` is now an alias for ``uint8``; it used to be an alias +- ``system.byte`` is now an alias for ``uint8``; it used to be an alias to ``int8``. - ``bind`` expressions in templates are not properly supported anymore. Use the declarative ``bind`` statement instead. - The default calling convention for a procedural **type** is now ``closure``, for procs it remains ``nimcall`` (which is compatible to ``closure``). - Activate the warning ``ImplicitClosure`` to make the compiler list the + Activate the warning ``ImplicitClosure`` to make the compiler list the occurrences of proc types which are affected. - The Nimrod type system now distinguishes ``openarray`` from ``varargs``. - Templates are now ``hygienic``. Use the ``dirty`` pragma to get the old behaviour. -- Objects that have no ancestor are now implicitly ``final``. Use - the ``inheritable`` pragma to introduce new object roots apart +- Objects that have no ancestor are now implicitly ``final``. Use + the ``inheritable`` pragma to introduce new object roots apart from ``TObject``. - Macros now receive parameters like templates do; use the ``callsite`` builtin to gain access to the invocation AST. @@ -772,14 +988,14 @@ Compiler Additions ------------------ - Win64 is now an officially supported target. -- The Nimrod compiler works on BSD again, but has some issues +- The Nimrod compiler works on BSD again, but has some issues as ``os.getAppFilename`` and ``os.getAppDir`` cannot work reliably on BSD. - The compiler can detect and evaluate calls that can be evaluated at compile time for optimization purposes with the ``--implicitStatic`` command line option or pragma. - The compiler now generates marker procs that the GC can use instead of RTTI. This speeds up the GC quite a bit. -- The compiler now includes a new advanced documentation generator +- The compiler now includes a new advanced documentation generator via the ``doc2`` command. This new generator uses all of the semantic passes of the compiler and can thus generate documentation for symbols hiding in macros. @@ -798,7 +1014,7 @@ Language Additions - Added ``global`` pragma that can be used to introduce new global variables from within procs. - ``when`` expressions are now allowed just like ``if`` expressions. -- The precedence for operators starting with ``@`` is different now +- The precedence for operators starting with ``@`` is different now allowing for *sigil-like* operators. - Stand-alone ``finally`` and ``except`` blocks are now supported. - Macros and templates can now be invoked as pragmas. @@ -806,7 +1022,7 @@ Language Additions - Unsigned integer types have been added. - The integer promotion rules changed. - Nimrod now tracks proper intervals for ``range`` over some built-in operators. -- In parameter lists a semicolon instead of a comma can be used to improve +- In parameter lists a semicolon instead of a comma can be used to improve readability: ``proc divmod(a, b: int; resA, resB: var int)``. - A semicolon can now be used to have multiple simple statements on a single line: ``inc i; inc j``. @@ -848,9 +1064,9 @@ Bugfixes Changes affecting backwards compatibility ----------------------------------------- -- Removed deprecated ``os.AppendFileExt``, ``os.executeShellCommand``, +- Removed deprecated ``os.AppendFileExt``, ``os.executeShellCommand``, ``os.iterOverEnvironment``, ``os.pcDirectory``, ``os.pcLinkToDirectory``, - ``os.SplitPath``, ``os.extractDir``, ``os.SplitFilename``, + ``os.SplitPath``, ``os.extractDir``, ``os.SplitFilename``, ``os.extractFileTrunk``, ``os.extractFileExt``, ``osproc.executeProcess``, ``osproc.executeCommand``. - Removed deprecated ``parseopt.init``, ``parseopt.getRestOfCommandLine``. @@ -860,7 +1076,7 @@ Changes affecting backwards compatibility - ``implies`` is no keyword anymore. - The ``is`` operator is now the ``of`` operator. - The ``is`` operator is now used to check type equivalence in generic code. -- The ``pure`` pragma for procs has been renamed to ``noStackFrame``. +- The ``pure`` pragma for procs has been renamed to ``noStackFrame``. - The threading API has been completely redesigned. - The ``unidecode`` module is now thread-safe and its interface has changed. - The ``bind`` expression is deprecated, use a ``bind`` declaration instead. @@ -870,13 +1086,13 @@ Changes affecting backwards compatibility - Changed exception handling/error reporting for ``os.removeFile`` and ``os.removeDir``. - The algorithm for searching and loading configuration files has been changed. -- Operators now have diffent precedence rules: Assignment-like operators - (like ``*=``) are now special-cased. -- The fields in ``TStream`` have been renamed to have an ``Impl`` suffix - because they should not be used directly anymore. +- Operators now have diffent precedence rules: Assignment-like operators + (like ``*=``) are now special-cased. +- The fields in ``TStream`` have been renamed to have an ``Impl`` suffix + because they should not be used directly anymore. Wrapper procs have been created that should be used instead. - ``export`` is now a keyword. -- ``assert`` is now implemented in pure Nimrod as a template; it's easy +- ``assert`` is now implemented in pure Nimrod as a template; it's easy to implement your own assertion templates with ``system.astToStr``. @@ -889,7 +1105,7 @@ Language Additions - Return types may be of the type ``var T`` to return an l-value. - The error pragma can now be used to mark symbols whose *usage* should trigger a compile-time error. -- There is a new ``discardable`` pragma that can be used to mark a routine +- There is a new ``discardable`` pragma that can be used to mark a routine so that its result can be discarded implicitly. - Added a new ``noinit`` pragma to prevent automatic initialization to zero of variables. @@ -900,7 +1116,7 @@ Language Additions - ``bind`` (used for symbol binding in templates and generics) is now a declarative statement. - Nimrod now supports single assignment variables via the ``let`` statement. -- Iterators named ``items`` and ``pairs`` are implicitly invoked when +- Iterators named ``items`` and ``pairs`` are implicitly invoked when an explicit iterator is missing. - The slice assignment ``a[i..j] = b`` where ``a`` is a sequence or string now supports *splicing*. @@ -918,9 +1134,9 @@ Compiler Additions definitions. - Added a ``--nimcache:PATH`` configuration option for control over the output directory for generated code. -- The ``--genScript`` option now produces different compilation scripts +- The ``--genScript`` option now produces different compilation scripts which do not contain absolute paths. -- Added ``--cincludes:dir``, ``--clibdir:lib`` configuration options for +- Added ``--cincludes:dir``, ``--clibdir:lib`` configuration options for modifying the C compiler's header/library search path in cross-platform way. - Added ``--clib:lib`` configuration option for specifying additional C libraries to be linked. @@ -935,7 +1151,7 @@ Compiler Additions are declared with the ``TaintedString`` string type. If the taint mode is turned on it is a distinct string type which helps to detect input validation errors. -- The compiler now supports the compilation cache via ``--symbolFiles:on``. +- The compiler now supports the compilation cache via ``--symbolFiles:on``. This potentially speeds up compilations by an order of magnitude, but is still highly experimental! - Added ``--import:file`` and ``--include:file`` configuration options @@ -947,7 +1163,7 @@ Compiler Additions for ``on|off`` switches in pragmas. In order to not break existing code, ``on`` and ``off`` are now aliases for ``true`` and ``false`` and declared in the system module. -- The compiler finally supports **closures**. This is a preliminary +- The compiler finally supports **closures**. This is a preliminary implementation, which does not yet support nestings deeper than 1 level and still has many known bugs. @@ -955,7 +1171,7 @@ Compiler Additions Library Additions ----------------- -- Added ``system.allocShared``, ``system.allocShared0``, +- Added ``system.allocShared``, ``system.allocShared0``, ``system.deallocShared``, ``system.reallocShared``. - Slicing as implemented by the system module now supports *splicing*. - Added explicit channels for thread communication. @@ -969,8 +1185,8 @@ Library Additions - Added ``os.isAbsolute``, ``os.dynLibFormat``, ``os.isRootDir``, ``os.parentDirs``. - Added ``parseutils.interpolatedFragments``. -- Added ``macros.treeRepr``, ``macros.lispRepr``, ``macros.dumpTree``, - ``macros.dumpLisp``, ``macros.parseExpr``, ``macros.parseStmt``, +- Added ``macros.treeRepr``, ``macros.lispRepr``, ``macros.dumpTree``, + ``macros.dumpLisp``, ``macros.parseExpr``, ``macros.parseStmt``, ``macros.getAst``. - Added ``locks`` core module for more flexible locking support. - Added ``irc`` module. @@ -982,7 +1198,7 @@ Library Additions - Added ``actors`` module. - Added ``algorithm`` module for generic ``sort``, ``reverse`` etc. operations. - Added ``osproc.startCmd``, ``osproc.execCmdEx``. -- The ``osproc`` module now uses ``posix_spawn`` instead of ``fork`` +- The ``osproc`` module now uses ``posix_spawn`` instead of ``fork`` and ``exec`` on Posix systems. Define the symbol ``useFork`` to revert to the old implementation. - Added ``intsets.assign``. @@ -1017,20 +1233,20 @@ Bugfixes Changes affecting backwards compatibility ----------------------------------------- -- Operators starting with ``^`` are now right-associative and have the highest +- Operators starting with ``^`` are now right-associative and have the highest priority. - Deprecated ``os.getApplicationFilename``: Use ``os.getAppFilename`` instead. - Deprecated ``os.getApplicationDir``: Use ``os.getAppDir`` instead. - Deprecated ``system.copy``: Use ``substr`` or string slicing instead. - Changed and documented how generalized string literals work: The syntax ``module.re"abc"`` is now supported. -- Changed the behaviour of ``strutils.%``, ``ropes.%`` +- Changed the behaviour of ``strutils.%``, ``ropes.%`` if both notations ``$#`` and ``$i`` are involved. -- The ``pegs`` and ``re`` modules distinguish between ``replace`` +- The ``pegs`` and ``re`` modules distinguish between ``replace`` and ``replacef`` operations. - The pointer dereference operation ``p^`` is deprecated and might become - ``^p`` in later versions or be dropped entirely since it is rarely used. - Use the new notation ``p[]`` in the rare cases where you need to + ``^p`` in later versions or be dropped entirely since it is rarely used. + Use the new notation ``p[]`` in the rare cases where you need to dereference a pointer explicitly. - ``system.readFile`` does not return ``nil`` anymore but raises an ``EIO`` exception instead. @@ -1046,15 +1262,15 @@ Language Additions - Case statement branches support constant sets for programming convenience. - Tuple unpacking is not enforced in ``for`` loops anymore. - The compiler now supports array, sequence and string slicing. -- A field in an ``enum`` may be given an explicit string representation. - This yields more maintainable code than using a constant +- A field in an ``enum`` may be given an explicit string representation. + This yields more maintainable code than using a constant ``array[TMyEnum, string]`` mapping. - Indices in array literals may be explicitly given, enhancing readability: ``[enumValueA: "a", enumValueB: "b"]``. -- Added thread support via the ``threads`` core module and +- Added thread support via the ``threads`` core module and the ``--threads:on`` command line switch. - The built-in iterators ``system.fields`` and ``system.fieldPairs`` can be - used to iterate over any field of a tuple. With this mechanism operations + used to iterate over any field of a tuple. With this mechanism operations like ``==`` and ``hash`` are lifted to tuples. - The slice ``..`` is now a first-class operator, allowing code like: ``x in 1000..100_000``. @@ -1064,12 +1280,12 @@ Compiler Additions ------------------ - The compiler supports IDEs via the new group of ``idetools`` command line - options. -- The *interactive mode* (REPL) has been improved and documented for the + options. +- The *interactive mode* (REPL) has been improved and documented for the first time. - The compiler now might use hashing for string case statements depending on the number of string literals in the case statement. - + Library Additions ----------------- @@ -1091,11 +1307,11 @@ Library Additions ``\title``, ``\white``. - Pegs support the new built-in ``\skip`` operation. - Pegs support the ``$`` and ``^`` anchors. -- Additional operations were added to the ``complex`` module. +- Additional operations were added to the ``complex`` module. - Added ``strutils.formatFloat``, ``strutils.formatBiggestFloat``. - Added unary ``<`` for nice looking excluding upper bounds in ranges. - Added ``math.floor``. -- Added ``system.reset`` and a version of ``system.open`` that +- Added ``system.reset`` and a version of ``system.open`` that returns a ``TFile`` and raises an exception in case of an error. - Added a wrapper for ``redis``. - Added a wrapper for ``0mq`` via the ``zmq`` module. @@ -1121,12 +1337,12 @@ Bugfixes - Bugfix: Passing a ``ref`` pointer to the untyped ``pointer`` type is invalid. - Bugfix: Updated ``keyval`` example. - Bugfix: ``system.splitChunk`` still contained code for debug output. -- Bugfix: ``dialogs.ChooseFileToSave`` uses ``STOCK_SAVE`` instead of +- Bugfix: ``dialogs.ChooseFileToSave`` uses ``STOCK_SAVE`` instead of ``STOCK_OPEN`` for the GTK backend. - Bugfix: Various bugs concerning exception handling fixed. - Bugfix: ``low(somestring)`` crashed the compiler. - Bugfix: ``strutils.endsWith`` lacked range checking. -- Bugfix: Better detection for AMD64 on Mac OS X. +- Bugfix: Better detection for AMD64 on Mac OS X. Changes affecting backwards compatibility @@ -1135,7 +1351,7 @@ Changes affecting backwards compatibility - Reversed parameter order for ``os.copyFile`` and ``os.moveFile``!!! - Procs not marked as ``procvar`` cannot only be passed to a procvar anymore, unless they are used in the same module. -- Deprecated ``times.getStartMilsecs``: Use ``epochTime`` or ``cpuTime`` +- Deprecated ``times.getStartMilsecs``: Use ``epochTime`` or ``cpuTime`` instead. - Removed ``system.OpenFile``. - Removed ``system.CloseFile``. @@ -1144,7 +1360,7 @@ Changes affecting backwards compatibility - Removed ``strutils.splitLinesSeq``. - Removed ``strutils.splitSeq``. - Removed ``strutils.toString``. -- If a DLL cannot be loaded (via the ``dynlib`` pragma) ``EInvalidLibrary`` +- If a DLL cannot be loaded (via the ``dynlib`` pragma) ``EInvalidLibrary`` is not raised anymore. Instead ``system.quit()`` is called. This is because raising an exception requires heap allocations. However the memory manager might be contained in the DLL that failed to load. @@ -1154,19 +1370,19 @@ Changes affecting backwards compatibility Additions --------- -- The ``{.compile: "file.c".}`` pragma uses a CRC check to see if the file +- The ``{.compile: "file.c".}`` pragma uses a CRC check to see if the file needs to be recompiled. -- Added ``system.reopen``. +- Added ``system.reopen``. - Added ``system.getCurrentException``. - Added ``system.appType``. -- Added ``system.compileOption``. -- Added ``times.epochTime`` and ``times.cpuTime``. +- Added ``system.compileOption``. +- Added ``times.epochTime`` and ``times.cpuTime``. - Implemented explicit type arguments for generics. - Implemented ``{.size: sizeof(cint).}`` pragma for enum types. This is useful for interfacing with C. - Implemented ``{.pragma.}`` pragma for user defined pragmas. - Implemented ``{.extern.}`` pragma for better control of name mangling. -- The ``importc`` and ``exportc`` pragmas support format strings: +- The ``importc`` and ``exportc`` pragmas support format strings: ``proc p{.exportc: "nim_$1".}`` exports ``p`` as ``nim_p``. This is useful for user defined pragmas. - The standard library can be built as a DLL. Generating DLLs has been @@ -1174,7 +1390,7 @@ Additions - Added ``expat`` module. - Added ``json`` module. - Added support for a *Tiny C* backend. Currently this only works on Linux. - You need to bootstrap with ``-d:tinyc`` to enable Tiny C support. Nimrod + You need to bootstrap with ``-d:tinyc`` to enable Tiny C support. Nimrod can then execute code directly via ``nimrod run myfile``. @@ -1193,9 +1409,9 @@ Bugfixes zeros. - Fixed a bug in ``os.setFilePermissions`` for Windows. - An overloadable symbol can now have the same name as an imported module. -- Fixed a serious bug in ``strutils.cmpIgnoreCase``. -- Fixed ``unicode.toUTF8``. -- The compiler now rejects ``'\n'`` (use ``"\n"`` instead). +- Fixed a serious bug in ``strutils.cmpIgnoreCase``. +- Fixed ``unicode.toUTF8``. +- The compiler now rejects ``'\n'`` (use ``"\n"`` instead). - ``times.getStartMilsecs()`` now works on Mac OS X. - Fixed a bug in ``pegs.match`` concerning start offsets. - Lots of other little bugfixes. @@ -1227,14 +1443,14 @@ Additions - Added ``graphics`` module. - Added ``colors`` module. - Many wrappers now do not contain redundant name prefixes (like ``GTK_``, - ``lua``). The old wrappers are still available in ``lib/oldwrappers``. + ``lua``). The old wrappers are still available in ``lib/oldwrappers``. You can change your configuration file to use these. - Triple quoted strings allow for ``"`` in more contexts. - ``""`` within raw string literals stands for a single quotation mark. - Arguments to ``openArray`` parameters can be left out. - More extensive subscript operator overloading. (To be documented.) - The documentation generator supports the ``.. raw:: html`` directive. -- The Pegs module supports back references via the notation ``$capture_index``. +- The Pegs module supports back references via the notation ``$capture_index``. Changes affecting backwards compatibility @@ -1242,9 +1458,9 @@ Changes affecting backwards compatibility - Overloading of the subscript operator only works if the type does not provide a built-in one. -- The search order for libraries which is affected by the ``path`` option - has been reversed, so that the project's path is searched before - the standard library's path. +- The search order for libraries which is affected by the ``path`` option + has been reversed, so that the project's path is searched before + the standard library's path. - The compiler does not include a Pascal parser for bootstrapping purposes any more. Instead there is a ``pas2nim`` tool that contains the old functionality. - The procs ``os.copyFile`` and ``os.moveFile`` have been deprecated @@ -1271,7 +1487,7 @@ Bugfixes - Method call syntax for iterators works again (``for x in lines.split()``). - Fixed a typo in ``removeDir`` for POSIX that lead to an infinite recursion. - The compiler now checks that module filenames are valid identifiers. -- Empty patterns for the ``dynlib`` pragma are now possible. +- Empty patterns for the ``dynlib`` pragma are now possible. - ``os.parseCmdLine`` returned wrong results for trailing whitespace. - Inconsequent tuple usage (using the same tuple with and without named fields) does not crash the code generator anymore. @@ -1300,11 +1516,11 @@ Changes affecting backwards compatibility has changed. - ``os.splitFile(".xyz")`` now returns ``("", ".xyz", "")`` instead of ``("", "", ".xyz")``. So filenames starting with a dot are handled - differently. + differently. - ``strutils.split(s: string, seps: set[char])`` never yields the empty string - anymore. This behaviour is probably more appropriate for whitespace splitting. + anymore. This behaviour is probably more appropriate for whitespace splitting. - The compiler now stops after the ``--version`` command line switch. -- Removed support for enum inheritance in the parser; enum inheritance has +- Removed support for enum inheritance in the parser; enum inheritance has never been documented anyway. - The ``msg`` field of ``system.E_base`` has now the type ``string``, instead of ``cstring``. This improves memory safety. |