From c751c914fc1306b18209175a8c223cf39b90f0a0 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Fri, 8 Feb 2019 20:01:20 +0100 Subject: [PATCH 01/50] koch and testament improvement; make testing command easier to get right --- koch.nim | 5 ----- testament/specs.nim | 2 +- testament/tester.nim | 6 +++++- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/koch.nim b/koch.nim index 9c73afe2b5..c91f3d6a68 100644 --- a/koch.nim +++ b/koch.nim @@ -412,13 +412,8 @@ template `|`(a, b): string = (if a.len > 0: a else: b) proc tests(args: string) = nimexec "cc --opt:speed testament/tester" - # Since tests take a long time (on my machine), and we want to defy Murhpys - # law - lets make sure the compiler really is freshly compiled! - nimexec "c --lib:lib -d:release --opt:speed compiler/nim.nim" let tester = quoteShell(getCurrentDir() / "testament/tester".exe) let success = tryExec tester & " " & (args|"all") - if not existsEnv("TRAVIS") and not existsEnv("APPVEYOR"): - exec tester & " html" if not success: quit("tests failed", QuitFailure) diff --git a/testament/specs.nim b/testament/specs.nim index 903e3e2823..bfc6b051ed 100644 --- a/testament/specs.nim +++ b/testament/specs.nim @@ -9,7 +9,7 @@ import parseutils, strutils, os, osproc, streams, parsecfg -var compilerPrefix* = "nim" +var compilerPrefix* = findExe("nim") let isTravis* = existsEnv("TRAVIS") let isAppVeyor* = existsEnv("APPVEYOR") diff --git a/testament/tester.nim b/testament/tester.nim index ad0d227425..9b3091fd5d 100644 --- a/testament/tester.nim +++ b/testament/tester.nim @@ -42,7 +42,7 @@ Options: --simulate see what tests would be run but don't run them (for debugging) --failing only show failing/ignored tests --targets:"c c++ js objc" run tests for specified targets (default: all) - --nim:path use a particular nim executable (default: compiler/nim) + --nim:path use a particular nim executable (default: $$PATH/nim) --directory:dir Change to directory dir before reading the tests or doing anything else. --colors:on|off Turn messagescoloring on|off. --backendLogging:on|off Disable or enable backend logging. By default turned on. @@ -537,6 +537,7 @@ proc main() = var optPrintResults = false var optFailing = false var targetsStr = "" + var isMainProcess = true var p = initOptParser() p.next() @@ -620,6 +621,7 @@ proc main() = # 'pcat' is used for running a category in parallel. Currently the only # difference is that we don't want to run joinable tests here as they # are covered by the 'megatest' category. + isMainProcess = false var cat = Category(p.key) p.next processCategory(r, cat, p.cmdLineRest.string, testsDir, runJoinableTests = false) @@ -644,6 +646,8 @@ proc main() = echo "FAILURE! total: ", r.total, " passed: ", r.passed, " skipped: ", r.skipped, " failed: ", failed quit(QuitFailure) + if isMainProcess: + echo "Used ", compilerPrefix, " to run the tests. Use --nim to override." if paramCount() == 0: quit Usage From e0e8fdf737ff8c70e8f80438f5bafd8a273dc159 Mon Sep 17 00:00:00 2001 From: b3liever <43617260+b3liever@users.noreply.github.com> Date: Fri, 8 Feb 2019 22:38:27 +0200 Subject: [PATCH 02/50] Add summation algorithms (#9284) --- changelog.md | 3 ++ lib/std/sums.nim | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 lib/std/sums.nim diff --git a/changelog.md b/changelog.md index 9382a194f9..211855bfc2 100644 --- a/changelog.md +++ b/changelog.md @@ -124,9 +124,12 @@ proc enumToString*(enums: openArray[enum]): string = - Added `xmltree.toXmlAttributes`. +- Added ``std/sums`` module for fast summation functions. + - Added `Rusage`, `getrusage`, `wait4` to posix interface. + ### Library changes - The string output of `macros.lispRepr` proc has been tweaked diff --git a/lib/std/sums.nim b/lib/std/sums.nim new file mode 100644 index 0000000000..dc9d8d5072 --- /dev/null +++ b/lib/std/sums.nim @@ -0,0 +1,78 @@ +# +# +# Nim's Runtime Library +# (c) Copyright 2019 b3liever +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. + +## Fast sumation functions. + + +func sumKbn*[T](x: openArray[T]): T = + ## Kahan (compensated) summation: O(1) error growth, at the expense + ## of a considerable increase in computational expense. + if len(x) == 0: return + var sum = x[0] + var c = T(0) + for i in 1 ..< len(x): + let xi = x[i] + let t = sum + xi + if abs(sum) >= abs(xi): + c += (sum - t) + xi + else: + c += (xi - t) + sum + sum = t + result = sum + c + +func sumPairwise[T](x: openArray[T], i0, n: int): T = + if n < 128: + result = x[i0] + for i in i0 + 1 ..< i0 + n: + result += x[i] + else: + let n2 = n div 2 + result = sumPairwise(x, i0, n2) + sumPairwise(x, i0 + n2, n - n2) + +func sumPairs*[T](x: openArray[T]): T = + ## Pairwise (cascade) summation of ``x[i0:i0+n-1]``, with O(log n) error growth + ## (vs O(n) for a simple loop) with negligible performance cost if + ## the base case is large enough. + ## + ## See, e.g.: + ## * http://en.wikipedia.org/wiki/Pairwise_summation + ## Higham, Nicholas J. (1993), "The accuracy of floating point + ## summation", SIAM Journal on Scientific Computing 14 (4): 783–799. + ## + ## In fact, the root-mean-square error growth, assuming random roundoff + ## errors, is only O(sqrt(log n)), which is nearly indistinguishable from O(1) + ## in practice. See: + ## * Manfred Tasche and Hansmartin Zeuner, Handbook of + ## Analytic-Computational Methods in Applied Mathematics (2000). + ## + let n = len(x) + if n == 0: T(0) else: sumPairwise(x, 0, n) + + +when isMainModule: + from math import pow + + var epsilon = 1.0 + while 1.0 + epsilon != 1.0: + epsilon /= 2.0 + let data = @[1.0, epsilon, -epsilon] + assert sumKbn(data) == 1.0 + assert sumPairs(data) != 1.0 # known to fail + assert (1.0 + epsilon) - epsilon != 1.0 + + var tc1: seq[float] + for n in 1 .. 1000: + tc1.add 1.0 / n.float + assert sumKbn(tc1) == 7.485470860550345 + assert sumPairs(tc1) == 7.485470860550345 + + var tc2: seq[float] + for n in 1 .. 1000: + tc2.add pow(-1.0, n.float) / n.float + assert sumKbn(tc2) == -0.6926474305598203 + assert sumPairs(tc2) == -0.6926474305598204 From 55fe7c114ed04cb18a8c33c0039ae66d6125c24f Mon Sep 17 00:00:00 2001 From: cooldome Date: Fri, 8 Feb 2019 21:42:45 +0100 Subject: [PATCH 03/50] Move cpp exception handler from system to excpt next to the signal handler (#9435) --- lib/system.nim | 20 -------------------- lib/system/excpt.nim | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index 7febde1274..ca4ac33cb3 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -4166,26 +4166,6 @@ template doAssertRaises*(exception: typedesc, code: untyped): typed = if wrong: raiseAssert(astToStr(exception) & " wasn't raised by:\n" & astToStr(code)) -when defined(cpp) and appType != "lib" and - not defined(js) and not defined(nimscript) and - hostOS != "standalone" and not defined(noCppExceptions): - proc setTerminate(handler: proc() {.noconv.}) - {.importc: "std::set_terminate", header: "".} - setTerminate proc() {.noconv.} = - # Remove ourself as a handler, reinstalling the default handler. - setTerminate(nil) - - let ex = getCurrentException() - let trace = ex.getStackTrace() - when defined(genode): - # stderr not available by default, use the LOG session - echo trace & "Error: unhandled exception: " & ex.msg & - " [" & $ex.name & "]\n" - else: - cstderr.rawWrite trace & "Error: unhandled exception: " & ex.msg & - " [" & $ex.name & "]\n" - quit 1 - when not defined(js): proc toOpenArray*[T](x: seq[T]; first, last: int): openarray[T] {. magic: "Slice".} diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim index 9d33db4cb8..dbdd038a47 100644 --- a/lib/system/excpt.nim +++ b/lib/system/excpt.nim @@ -469,6 +469,24 @@ when defined(endb): var dbgAborting: bool # whether the debugger wants to abort +when defined(cpp) and appType != "lib" and + not defined(js) and not defined(nimscript) and + hostOS != "standalone" and not defined(noCppExceptions): + proc setTerminate(handler: proc() {.noconv.}) + {.importc: "std::set_terminate", header: "".} + setTerminate proc() {.noconv.} = + # Remove ourself as a handler, reinstalling the default handler. + setTerminate(nil) + + when defined(genode): + # stderr not available by default, use the LOG session + echo currException.getStackTrace() & "Error: unhandled exception: " & + currException.msg & " [" & $currException.name & "]\n" + else: + writeToStdErr currException.getStackTrace() & "Error: unhandled exception: " & + currException.msg & " [" & $currException.name & "]\n" + quit 1 + when not defined(noSignalHandler) and not defined(useNimRtl): proc signalHandler(sign: cint) {.exportc: "signalHandler", noconv.} = template processSignal(s, action: untyped) {.dirty.} = From bcbe130ea79fa34007bc0a9a662e026870ba29a6 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 9 Feb 2019 07:30:48 +0100 Subject: [PATCH 04/50] Fix compilation w/ Atomic[T] types (#10607) --- lib/pure/concurrency/atomics.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pure/concurrency/atomics.nim b/lib/pure/concurrency/atomics.nim index 9e716bdf4b..b9d45681ef 100644 --- a/lib/pure/concurrency/atomics.nim +++ b/lib/pure/concurrency/atomics.nim @@ -136,7 +136,7 @@ else: # A type that is known to be atomic and whose size is known at # compile time to be 8 bytes or less - template nonAtomicType(T: typedesc[Trivial]): untyped = + template nonAtomicType*(T: typedesc[Trivial]): untyped = # Maps types to integers of the same size when sizeof(T) == 1: int8 elif sizeof(T) == 2: int16 @@ -252,7 +252,7 @@ else: AtomicInt32 {.importc: "_Atomic NI32".} = object AtomicInt64 {.importc: "_Atomic NI64".} = object - template atomicType(T: typedesc[Trivial]): untyped = + template atomicType*(T: typedesc[Trivial]): untyped = # Maps the size of a trivial type to it's internal atomic type when sizeof(T) == 1: AtomicInt8 elif sizeof(T) == 2: AtomicInt16 From 594c2576e6aceb4eb37ed783f5351feca2557acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20D=C3=B6ring?= Date: Sat, 9 Feb 2019 07:36:30 +0100 Subject: [PATCH 05/50] Print missing case labels (#10600) --- compiler/semstmts.nim | 3 + compiler/semtypes.nim | 24 ++++- tests/casestmt/tcaseexpr1.nim | 2 +- tests/casestmt/tincompletecaseobject.nim | 115 +++++++++++++++++++++++ 4 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 tests/casestmt/tincompletecaseobject.nim diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 5e9c88f2b3..5b7556b2e9 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -873,6 +873,9 @@ proc semCase(c: PContext, n: PNode; flags: TExprFlags): PNode = if chckCovered: if covered == toCover(c, n.sons[0].typ): hasElse = true + elif n.sons[0].typ.kind == tyEnum: + localError(c.config, n.info, "not all cases are covered; missing: {$1}" % + formatMissingEnums(n)) else: localError(c.config, n.info, "not all cases are covered") closeScope(c) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 7447463238..d62bc664e3 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -608,6 +608,24 @@ proc toCover(c: PContext, t: PType): BiggestInt = proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int, father: PNode, rectype: PType, hasCaseFields = false) + +proc formatMissingEnums(n: PNode): string = + var coveredCases = initIntSet() + for i in 1 ..< n.len: + let ofBranch = n[i] + for j in 0 ..< ofBranch.len - 1: + let child = ofBranch[j] + if child.kind == nkIntLit: + coveredCases.incl(child.intVal.int) + elif child.kind == nkRange: + for k in child[0].intVal.int .. child[1].intVal.int: + coveredCases.incl k + for child in n[0].typ.n.sons: + if child.sym.position notin coveredCases: + if result.len > 0: + result.add ", " + result.add child.sym.name.s + proc semRecordCase(c: PContext, n: PNode, check: var IntSet, pos: var int, father: PNode, rectype: PType) = var a = copyNode(n) @@ -644,7 +662,11 @@ proc semRecordCase(c: PContext, n: PNode, check: var IntSet, pos: var int, delSon(b, sonsLen(b) - 1) semRecordNodeAux(c, lastSon(n.sons[i]), check, pos, b, rectype, hasCaseFields = true) if chckCovered and covered != toCover(c, a.sons[0].typ): - localError(c.config, a.info, "not all cases are covered") + if a.sons[0].typ.kind == tyEnum: + localError(c.config, a.info, "not all cases are covered; missing: {$1}" % + formatMissingEnums(a)) + else: + localError(c.config, a.info, "not all cases are covered") addSon(father, a) proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int, diff --git a/tests/casestmt/tcaseexpr1.nim b/tests/casestmt/tcaseexpr1.nim index 4fdac8191b..3d4b6c0872 100644 --- a/tests/casestmt/tcaseexpr1.nim +++ b/tests/casestmt/tcaseexpr1.nim @@ -3,7 +3,7 @@ discard """ line: 33 file: "tcaseexpr1.nim" - errormsg: "not all cases are covered" + errormsg: "not all cases are covered; missing: {C}" line: 27 file: "tcaseexpr1.nim" """ diff --git a/tests/casestmt/tincompletecaseobject.nim b/tests/casestmt/tincompletecaseobject.nim new file mode 100644 index 0000000000..909ee4e1c3 --- /dev/null +++ b/tests/casestmt/tincompletecaseobject.nim @@ -0,0 +1,115 @@ +discard """ +errormsg: ''' +not all cases are covered; missing: {nnkComesFrom, nnkDotCall, nnkHiddenCallConv, nnkVarTuple, nnkCurlyExpr, nnkRange, nnkCheckedFieldExpr, nnkDerefExpr, nnkElifExpr, nnkElseExpr, nnkLambda, nnkDo, nnkBind, nnkClosedSymChoice, nnkHiddenSubConv, nnkConv, nnkStaticExpr, nnkAddr, nnkHiddenAddr, nnkHiddenDeref, nnkObjDownConv, nnkObjUpConv, nnkChckRangeF, nnkChckRange64, nnkChckRange, nnkStringToCString, nnkCStringToString, nnkFastAsgn, nnkGenericParams, nnkFormalParams, nnkOfInherit, nnkImportAs, nnkConverterDef, nnkMacroDef, nnkTemplateDef, nnkIteratorDef, nnkOfBranch, nnkElifBranch, nnkExceptBranch, nnkElse, nnkAsmStmt, nnkTypeDef, nnkFinally, nnkContinueStmt, nnkImportStmt, nnkImportExceptStmt, nnkExportStmt, nnkExportExceptStmt, nnkFromStmt, nnkIncludeStmt, nnkUsingStmt, nnkBlockExpr, nnkStmtListType, nnkBlockType, nnkWith, nnkWithout, nnkTypeOfExpr, nnkObjectTy, nnkTupleTy, nnkTupleClassTy, nnkTypeClassTy, nnkStaticTy, nnkRecList, nnkRecCase, nnkRecWhen, nnkVarTy, nnkConstTy, nnkMutableTy, nnkDistinctTy, nnkProcTy, nnkIteratorTy, nnkSharedTy, nnkEnumTy, nnkEnumFieldDef, nnkArglist, nnkPattern, nnkReturnToken, nnkClosure, nnkGotoState, nnkState, nnkBreakState, nnkFuncDef, nnkTupleConstr} +''' +""" + +# this isn't imported from macros.nim to make it robust against possible changes in the ast. + +type + NimNodeKind* = enum + nnkNone, nnkEmpty, nnkIdent, nnkSym, + nnkType, nnkCharLit, nnkIntLit, nnkInt8Lit, + nnkInt16Lit, nnkInt32Lit, nnkInt64Lit, nnkUIntLit, nnkUInt8Lit, + nnkUInt16Lit, nnkUInt32Lit, nnkUInt64Lit, nnkFloatLit, + nnkFloat32Lit, nnkFloat64Lit, nnkFloat128Lit, nnkStrLit, nnkRStrLit, + nnkTripleStrLit, nnkNilLit, nnkComesFrom, nnkDotCall, + nnkCommand, nnkCall, nnkCallStrLit, nnkInfix, + nnkPrefix, nnkPostfix, nnkHiddenCallConv, + nnkExprEqExpr, + nnkExprColonExpr, nnkIdentDefs, nnkVarTuple, + nnkPar, nnkObjConstr, nnkCurly, nnkCurlyExpr, + nnkBracket, nnkBracketExpr, nnkPragmaExpr, nnkRange, + nnkDotExpr, nnkCheckedFieldExpr, nnkDerefExpr, nnkIfExpr, + nnkElifExpr, nnkElseExpr, nnkLambda, nnkDo, nnkAccQuoted, + nnkTableConstr, nnkBind, + nnkClosedSymChoice, + nnkOpenSymChoice, + nnkHiddenStdConv, + nnkHiddenSubConv, nnkConv, nnkCast, nnkStaticExpr, + nnkAddr, nnkHiddenAddr, nnkHiddenDeref, nnkObjDownConv, + nnkObjUpConv, nnkChckRangeF, nnkChckRange64, nnkChckRange, + nnkStringToCString, nnkCStringToString, nnkAsgn, + nnkFastAsgn, nnkGenericParams, nnkFormalParams, nnkOfInherit, + nnkImportAs, nnkProcDef, nnkMethodDef, nnkConverterDef, + nnkMacroDef, nnkTemplateDef, nnkIteratorDef, nnkOfBranch, + nnkElifBranch, nnkExceptBranch, nnkElse, + nnkAsmStmt, nnkPragma, nnkPragmaBlock, nnkIfStmt, nnkWhenStmt, + nnkForStmt, nnkParForStmt, nnkWhileStmt, nnkCaseStmt, + nnkTypeSection, nnkVarSection, nnkLetSection, nnkConstSection, + nnkConstDef, nnkTypeDef, + nnkYieldStmt, nnkDefer, nnkTryStmt, nnkFinally, nnkRaiseStmt, + nnkReturnStmt, nnkBreakStmt, nnkContinueStmt, nnkBlockStmt, nnkStaticStmt, + nnkDiscardStmt, nnkStmtList, + nnkImportStmt = 1337, # make a hole just for fun + nnkImportExceptStmt, + nnkExportStmt, + nnkExportExceptStmt, + nnkFromStmt, + nnkIncludeStmt, + nnkBindStmt, nnkMixinStmt, nnkUsingStmt, + nnkCommentStmt, nnkStmtListExpr, nnkBlockExpr, + nnkStmtListType, nnkBlockType, + nnkWith, nnkWithout, + nnkTypeOfExpr, nnkObjectTy, + nnkTupleTy, nnkTupleClassTy, nnkTypeClassTy, nnkStaticTy, + nnkRecList, nnkRecCase, nnkRecWhen, + nnkRefTy, nnkPtrTy, nnkVarTy, + nnkConstTy, nnkMutableTy, + nnkDistinctTy, + nnkProcTy, + nnkIteratorTy, # iterator type + nnkSharedTy, # 'shared T' + nnkEnumTy, + nnkEnumFieldDef, + nnkArglist, nnkPattern + nnkReturnToken, + nnkClosure, + nnkGotoState, + nnkState, + nnkBreakState, + nnkFuncDef, + nnkTupleConstr + +const + nnkLiterals* = {nnkCharLit..nnkNilLit} + + nnkSomething* = {nnkStmtList, nnkStmtListExpr, nnkDiscardStmt, nnkVarSection, nnkLetSection, + nnkConstSection, nnkPar, nnkAccQuoted, nnkAsgn, nnkDefer, nnkCurly, nnkBracket, + nnkStaticStmt, nnkTableConstr, nnkExprColonExpr, nnkInfix, nnkPrefix, + nnkRaiseStmt, nnkYieldStmt, nnkBracketExpr, nnkDotExpr, nnkCast, nnkBlockStmt, + nnkExprEqExpr} + +type + MyFictionalType = object + a: int + case n: NimNodeKind + of nnkLiterals, nnkCommentStmt, nnkNone, nnkEmpty, nnkIdent, nnkSym, + nnkType, nnkBindStmt, nnkMixinStmt, nnkTypeSection, nnkPragmaBlock, + nnkPragmaExpr, nnkPragma, nnkBreakStmt, nnkCallStrLit, nnkPostfix, + nnkOpenSymChoice: + b: int + of nnkCall, nnkCommand: + c: int + of nnkReturnStmt: + d: int + of nnkForStmt, nnkParForStmt, nnkWhileStmt, nnkProcDef, nnkMethodDef: + e: int + of nnkSomething, nnkRefTy, nnkPtrTy, nnkHiddenStdConv: + f: int + of nnkObjConstr: + g: int + of nnkIfStmt, nnkIfExpr, nnkWhenStmt: + # if when and case statements are branching statements. So a + # single function call is allowed to be in all of the braches and + # the entire expression can still be considered as a forwarding + # template. + h: int + of nnkCaseStmt: + i: int + of nnkTryStmt: + j: int + of nnkIdentDefs: + k: int + of nnkConstDef: + l: int From dee9a942784779859707efcffb4cca5a7bcc0bc4 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sat, 9 Feb 2019 07:40:00 +0100 Subject: [PATCH 06/50] =?UTF-8?q?new=20AppVeyor=20configuration=20that=20s?= =?UTF-8?q?hould=20test=20the=20compiler=20against=20sele=E2=80=A6=20(#105?= =?UTF-8?q?49)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appveyor.yml | 29 ++++++++++---------- koch.nim | 47 ++++++++++++++++---------------- testament/important_packages.nim | 4 +-- 3 files changed, 39 insertions(+), 41 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 8c4b2a07e7..9633bd15a5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,23 +5,22 @@ cache: - sqlite-dll-win64-x64-3160200.zip # - i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z -matrix: - fast_finish: true - environment: + MINGW_DIR: mingw64 + MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z/download + MINGW_ARCHIVE: x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z + SQLITE_URL: http://www.sqlite.org/2017/sqlite-dll-win64-x64-3160200.zip + SQLITE_ARCHIVE: sqlite-dll-win64-x64-3160200.zip + platform: x64 + matrix: - - MINGW_DIR: mingw64 - MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z/download - MINGW_ARCHIVE: x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z - SQLITE_URL: http://www.sqlite.org/2017/sqlite-dll-win64-x64-3160200.zip - SQLITE_ARCHIVE: sqlite-dll-win64-x64-3160200.zip - platform: x64 - # - MINGW_DIR: mingw32 - # MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/dwarf/i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z/download - # MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z - # SQLITE_URL: http://www.sqlite.org/2017/sqlite-dll-win32-x86-3160200.zip - # SQLITE_ARCHIVE: sqlite-dll-win32-x86-3160200.zip - # platform: x86 + - NIM_TEST_PACKAGES: true + - NIM_TEST_PACKAGES: false + +matrix: + #allow_failures: + # - NIM_TEST_PACKAGES: true + fast_finish: true install: - ps: Install-Product node 8 # node 8 or later is required to test js async stuff diff --git a/koch.nim b/koch.nim index c91f3d6a68..92fc3a7663 100644 --- a/koch.nim +++ b/koch.nim @@ -467,34 +467,33 @@ proc runCI(cmd: string) = ## build nimble early on to enable remainder to depend on it if needed kochExecFold("Build Nimble", "nimble") - when false: - for pkg in "zip opengl sdl1 jester@#head niminst".split: - exec "nimble install -y" & pkg + if getEnv("NIM_TEST_PACKAGES", "false") == "true": + execFold("Test selected Nimble packages", "nim c -r testament/tester cat nimble-extra") + else: + buildTools() # altenatively, kochExec "tools --toolsNoNimble" - buildTools() # altenatively, kochExec "tools --toolsNoNimble" + ## run tests + execFold("Test nimscript", "nim e tests/test_nimscript.nims") + when defined(windows): + # note: will be over-written below + execFold("Compile tester", "nim c -d:nimCoroutines --os:genode -d:posix --compileOnly testament/tester") - ## run tests - execFold("Test nimscript", "nim e tests/test_nimscript.nims") - when defined(windows): - # note: will be over-written below - execFold("Compile tester", "nim c -d:nimCoroutines --os:genode -d:posix --compileOnly testament/tester") + # main bottleneck here + execFold("Run tester", "nim c -r -d:nimCoroutines testament/tester --pedantic all -d:nimCoroutines") - # main bottleneck here - execFold("Run tester", "nim c -r -d:nimCoroutines testament/tester --pedantic all -d:nimCoroutines") + execFold("Run nimdoc tests", "nim c -r nimdoc/tester") + execFold("Run nimpretty tests", "nim c -r nimpretty/tester.nim") + when defined(posix): + execFold("Run nimsuggest tests", "nim c -r nimsuggest/tester") - execFold("Run nimdoc tests", "nim c -r nimdoc/tester") - execFold("Run nimpretty tests", "nim c -r nimpretty/tester.nim") - when defined(posix): - execFold("Run nimsuggest tests", "nim c -r nimsuggest/tester") - - ## remaining actions - when defined(posix): - kochExecFold("Docs", "docs --git.commit:devel") - kochExecFold("C sources", "csource") - elif defined(windows): - when false: - kochExec "csource" - kochExec "zip" + ## remaining actions + when defined(posix): + kochExecFold("Docs", "docs --git.commit:devel") + kochExecFold("C sources", "csource") + elif defined(windows): + when false: + kochExec "csource" + kochExec "zip" proc pushCsources() = if not dirExists("../csources/.git"): diff --git a/testament/important_packages.nim b/testament/important_packages.nim index 6607783abe..fbb3edaa8b 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -8,11 +8,11 @@ var packages*: seq[tuple[name, cmd, version: string]] = @[] pkg "karax" pkg "cligen" pkg "glob" -pkg "regex" +#pkg "regex" pkg "freeimage", "nim c freeimage.nim" pkg "zero_functional" pkg "nimpy", "nim c nimpy.nim" -pkg "nimongo", "nimble test_ci" +#pkg "nimongo", "nimble test_ci" pkg "inim" pkg "sdl1", "nim c src/sdl.nim" From c4ad29754450769b82ea8b5751b1ef995f0f87fd Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sat, 9 Feb 2019 07:41:11 +0100 Subject: [PATCH 07/50] disable flaky coroutines test --- tests/coroutines/texceptions.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/coroutines/texceptions.nim b/tests/coroutines/texceptions.nim index 323eb055d9..7b5d57ec0b 100644 --- a/tests/coroutines/texceptions.nim +++ b/tests/coroutines/texceptions.nim @@ -1,5 +1,6 @@ discard """ target: "c" + disabled: true """ import coro From 3c909ae8ff27048f5ba04023dd620a10b05428a7 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sat, 9 Feb 2019 08:18:33 +0100 Subject: [PATCH 08/50] fixes #10606 --- compiler/passes.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/passes.nim b/compiler/passes.nim index 50fc13e1e2..f45ee03f78 100644 --- a/compiler/passes.nim +++ b/compiler/passes.nim @@ -167,7 +167,9 @@ proc processModule*(graph: ModuleGraph; module: PSym, stream: PLLStream): bool { if graph.stopCompile(): break var n = parseTopLevelStmt(p) if n.kind == nkEmpty: break - if {sfNoForward, sfReorder} * module.flags != {}: + if sfSystemModule notin module.flags and + ({sfNoForward, sfReorder} * module.flags != {} or + codeReordering in graph.config.features): # read everything, no streaming possible var sl = newNodeI(nkStmtList, n.info) sl.add n @@ -175,7 +177,7 @@ proc processModule*(graph: ModuleGraph; module: PSym, stream: PLLStream): bool { var n = parseTopLevelStmt(p) if n.kind == nkEmpty: break sl.add n - if sfReorder in module.flags: + if sfReorder in module.flags or codeReordering in graph.config.features: sl = reorder(graph, sl, module) discard processTopLevelStmt(graph, sl, a) break From c6fdf93c7fb136864aa873945409ddfc74228596 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sat, 9 Feb 2019 11:18:21 +0100 Subject: [PATCH 09/50] fixes #6955 --- compiler/sempass2.nim | 10 +++++++--- tests/effects/tgcsafe.nim | 11 ++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index b453971c2c..923558a8d4 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -572,10 +572,14 @@ proc isNoEffectList(n: PNode): bool {.inline.} = assert n.kind == nkEffectList n.len == 0 or (n[tagEffects] == nil and n[exceptionEffects] == nil) -proc trackOperand(tracked: PEffects, n: PNode, paramType: PType) = +proc isTrival(caller: PNode): bool {.inline.} = + result = caller.kind == nkSym and caller.sym.magic in {mEqProc, mIsNil} + +proc trackOperand(tracked: PEffects, n: PNode, paramType: PType; caller: PNode) = let a = skipConvAndClosure(n) let op = a.typ - if op != nil and op.kind == tyProc and n.skipConv.kind != nkNilLit: + # assume indirect calls are taken here: + if op != nil and op.kind == tyProc and n.skipConv.kind != nkNilLit and not isTrival(caller): internalAssert tracked.config, op.n.sons[0].kind == nkEffectList var effectList = op.n.sons[0] var s = n.skipConv @@ -773,7 +777,7 @@ proc track(tracked: PEffects, n: PNode) = if not (a.kind == nkSym and a.sym == tracked.owner): markSideEffect(tracked, a) if a.kind != nkSym or a.sym.magic != mNBindSym: - for i in 1 ..< len(n): trackOperand(tracked, n.sons[i], paramType(op, i)) + for i in 1 ..< len(n): trackOperand(tracked, n.sons[i], paramType(op, i), a) if a.kind == nkSym and a.sym.magic in {mNew, mNewFinalize, mNewSeq}: # may not look like an assignment, but it is: let arg = n.sons[1] diff --git a/tests/effects/tgcsafe.nim b/tests/effects/tgcsafe.nim index ff207df59e..363624f195 100644 --- a/tests/effects/tgcsafe.nim +++ b/tests/effects/tgcsafe.nim @@ -1,9 +1,18 @@ discard """ errormsg: "'mainUnsafe' is not GC-safe" - line: 17 + line: 26 cmd: "nim $target --hints:on --threads:on $options $file" """ +# bug #6955 +var global_proc: proc(a: string): int {.nimcall.} = nil + +proc myproc(i: int) {.gcsafe.} = + if global_proc != nil: + echo "a" + if isNil(global_proc): + return + proc mymap(x: proc ()) = x() From dcf725d228ea0bd7720fc35b735b685badafded6 Mon Sep 17 00:00:00 2001 From: Kobi Date: Sat, 9 Feb 2019 15:12:59 +0200 Subject: [PATCH 10/50] fix replacef typo in example --- lib/impure/re.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/impure/re.nim b/lib/impure/re.nim index 42be4a3c29..4f32cd5fb9 100644 --- a/lib/impure/re.nim +++ b/lib/impure/re.nim @@ -451,7 +451,7 @@ proc replacef*(s: string, sub: Regex, by: string): string = ## ## .. code-block:: nim ## - ## "var1<-keykey; val2<-key2key2" + ## "var1<-keykey; var2<-key2key2" result = "" var caps: array[MaxSubpatterns, string] var prev = 0 From 1e88bf1defe2aeb18394e4130f019acb70a63c75 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 9 Feb 2019 18:22:07 +0100 Subject: [PATCH 11/50] Misc macro things (#10612) * Misc cleanup in macro code Generate error messages using `error` instead of `assert`. Fixes #10574 * Fix crash with hasCustomPragma on quoted fields Use the `$` operator instead of reaching for the `strVal` field directly --- lib/core/macros.nim | 31 ++++++++++++++++++------------- tests/pragmas/tcustom_pragma.nim | 2 +- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 05c54df913..8cbcc54dfe 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -1027,7 +1027,10 @@ const nnkCallStrLit, nnkHiddenCallConv} proc expectKind*(n: NimNode; k: set[NimNodeKind]) {.compileTime.} = - assert n.kind in k, "Expected one of " & $k & ", got " & $n.kind + ## checks that `n` is of kind `k`. If this is not the case, + ## compilation aborts with an error message. This is useful for writing + ## macros that check the AST that is passed to them. + if n.kind notin k: error("Expected one of " & $k & ", got " & $n.kind, n) proc newProc*(name = newEmptyNode(); params: openArray[NimNode] = [newEmptyNode()]; body: NimNode = newStmtList(), procType = nnkProcDef): NimNode {.compileTime.} = @@ -1035,7 +1038,8 @@ proc newProc*(name = newEmptyNode(); params: openArray[NimNode] = [newEmptyNode( ## ## The ``params`` array must start with the return type of the proc, ## followed by a list of IdentDefs which specify the params. - assert procType in RoutineNodes + if procType notin RoutineNodes: + error("Expected one of " & $RoutineNodes & ", got " & $procType) result = newNimNode(procType).add( name, newEmptyNode(), @@ -1077,7 +1081,8 @@ proc newEnum*(name: NimNode, fields: openArray[NimNode], ## expectKind name, nnkIdent - doAssert len(fields) > 0, "Enum must contain at least one field" + if len(fields) < 1: + error("Enum must contain at least one field") for field in fields: expectKind field, {nnkIdent, nnkEnumFieldDef} @@ -1133,7 +1138,7 @@ proc params*(someProc: NimNode): NimNode {.compileTime.} = result = someProc[3] proc `params=`* (someProc: NimNode; params: NimNode) {.compileTime.}= someProc.expectRoutine - assert params.kind == nnkFormalParams + expectKind(params, nnkFormalParams) someProc[3] = params proc pragma*(someProc: NimNode): NimNode {.compileTime.} = @@ -1144,7 +1149,7 @@ proc pragma*(someProc: NimNode): NimNode {.compileTime.} = proc `pragma=`*(someProc: NimNode; val: NimNode){.compileTime.}= ## Set the pragma of a proc type someProc.expectRoutine - assert val.kind in {nnkEmpty, nnkPragma} + expectKind(val, {nnkEmpty, nnkPragma}) someProc[4] = val proc addPragma*(someProc, pragma: NimNode) {.compileTime.} = @@ -1156,8 +1161,8 @@ proc addPragma*(someProc, pragma: NimNode) {.compileTime.} = someProc.pragma = pragmaNode pragmaNode.add(pragma) -template badNodeKind(k, f) = - assert false, "Invalid node kind " & $k & " for macros.`" & $f & "`" +template badNodeKind(n, f) = + error("Invalid node kind " & $n.kind & " for macros.`" & $f & "`", n) proc body*(someProc: NimNode): NimNode {.compileTime.} = case someProc.kind: @@ -1168,7 +1173,7 @@ proc body*(someProc: NimNode): NimNode {.compileTime.} = of nnkForStmt: return someProc.last else: - badNodeKind someProc.kind, "body" + badNodeKind someProc, "body" proc `body=`*(someProc: NimNode, val: NimNode) {.compileTime.} = case someProc.kind @@ -1179,7 +1184,7 @@ proc `body=`*(someProc: NimNode, val: NimNode) {.compileTime.} = of nnkForStmt: someProc[len(someProc)-1] = val else: - badNodeKind someProc.kind, "body=" + badNodeKind someProc, "body=" proc basename*(a: NimNode): NimNode {.compiletime, benign.} @@ -1195,7 +1200,7 @@ proc `$`*(node: NimNode): string {.compileTime.} = of nnkAccQuoted: result = $node[0] else: - badNodeKind node.kind, "$" + badNodeKind node, "$" proc ident*(name: string): NimNode {.magic: "StrToIdent", noSideEffect.} ## Create a new ident node from a string @@ -1281,7 +1286,7 @@ proc unpackPrefix*(node: NimNode): tuple[node: NimNode; op: string] {. proc unpackInfix*(node: NimNode): tuple[left: NimNode; op: string; right: NimNode] {.compileTime.} = - assert node.kind == nnkInfix + expectKind(node, nnkInfix) result = (node[1], $node[0], node[2]) proc copy*(node: NimNode): NimNode {.compileTime.} = @@ -1342,7 +1347,7 @@ else: proc hasArgOfName*(params: NimNode; name: string): bool {.compiletime.}= ## Search nnkFormalParams for an argument. - assert params.kind == nnkFormalParams + expectKind(params, nnkFormalParams) for i in 1 ..< params.len: template node: untyped = params[i] if name.eqIdent( $ node[0]): @@ -1451,7 +1456,7 @@ proc customPragmaNode(n: NimNode): NimNode = if varName.kind == nnkPostfix: # This is a public field. We are skipping the postfix * varName = varName[1] - if eqIdent(varName.strVal, name): + if eqIdent($varName, name): return varNode[1] if obj[1].kind == nnkOfInherit: # explore the parent object diff --git a/tests/pragmas/tcustom_pragma.nim b/tests/pragmas/tcustom_pragma.nim index 7f781f6f19..0dc85cf67a 100644 --- a/tests/pragmas/tcustom_pragma.nim +++ b/tests/pragmas/tcustom_pragma.nim @@ -22,7 +22,7 @@ import custom_pragma block: # A bit more advanced case type Subfield {.defaultValue: "catman".} = object - c* {.serializationKey: "cc".}: float + `c`* {.serializationKey: "cc".}: float MySerializable = object a {.serializationKey"asdf", defaultValue: 5.} : int From 0c4d1fd10b0c69cef2597a59799d87110d613eae Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 9 Feb 2019 19:55:26 +0100 Subject: [PATCH 12/50] Do not walk into type sub-nodes for cast/conv expr (#10616) --- compiler/destroyer.nim | 6 ++++++ tests/destructor/tcast.nim | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/destructor/tcast.nim diff --git a/compiler/destroyer.nim b/compiler/destroyer.nim index 22ace36349..6c47c8884e 100644 --- a/compiler/destroyer.nim +++ b/compiler/destroyer.nim @@ -601,6 +601,12 @@ proc p(n: PNode; c: var Con): PNode = of nkNone..nkNilLit, nkTypeSection, nkProcDef, nkConverterDef, nkMethodDef, nkIteratorDef, nkMacroDef, nkTemplateDef, nkLambda, nkDo, nkFuncDef: result = n + of nkCast, nkHiddenStdConv, nkHiddenSubConv, nkConv: + result = copyNode(n) + # Destination type + result.add n[0] + # Analyse the inner expression + result.add p(n[1], c) else: result = copyNode(n) recurse(n, result) diff --git a/tests/destructor/tcast.nim b/tests/destructor/tcast.nim new file mode 100644 index 0000000000..7d5a1954c1 --- /dev/null +++ b/tests/destructor/tcast.nim @@ -0,0 +1,18 @@ +discard """ + cmd: '''nim c --newruntime $file''' +""" + +# Make sure we don't walk cast[T] type section while injecting sinks/destructors +block: + type + XY[T] = object + discard + + proc `=`[T](x: var XY[T]; v: XY[T]) {.error.} + proc `=sink`[T](x: var XY[T]; v: XY[T]) {.error.} + + proc main[T]() = + var m = cast[ptr XY[T]](alloc0(sizeof(XY[T]))) + doAssert(m != nil) + + main[int]() From f1ae0ed6ea9b15e86f437e836d6a255630e4b181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20Nihlg=C3=A5rd?= Date: Sat, 9 Feb 2019 22:34:35 +0100 Subject: [PATCH 13/50] Implement `json.%` for tables and options --- lib/pure/json.nim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 176da1d9dc..e387c516b8 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -143,7 +143,7 @@ runnableExamples: import hashes, tables, strutils, lexbase, streams, unicode, macros, parsejson, - typetraits + typetraits, options export tables.`$` @@ -344,6 +344,16 @@ proc `%`*[T](elements: openArray[T]): JsonNode = result = newJArray() for elem in elements: result.add(%elem) +proc `%`*[T](table: Table[string, T]|OrderedTable[string, T]): JsonNode = + ## Generic constructor for JSON data. Creates a new ``JObject JsonNode``. + result = newJObject() + for k, v in table: result[k] = %v + +proc `%`*[T](opt: Option[T]): JsonNode = + ## Generic constructor for JSON data. Creates a new ``JNull JsonNode`` + ## if ``opt`` is empty, otherwise it delegates to the underlying value. + if opt.isSome: %opt.get else: newJNull() + when false: # For 'consistency' we could do this, but that only pushes people further # into that evil comfort zone where they can use Nim without understanding it From 0c9a3d48042fc28978dd01020e3a759a55b0e04c Mon Sep 17 00:00:00 2001 From: Brent Pedersen Date: Sun, 10 Feb 2019 00:49:54 -0700 Subject: [PATCH 14/50] sets: avoid calling countBits32 for 0 (#10619) this speeds up the system.sets time from ~0.2 to ~0.06 in release mode. This is still slower than intsets and tables (which both are ~0.01). This assumes that most sets will be sparse. fixes #10617 --- lib/system/sets.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/system/sets.nim b/lib/system/sets.nim index a5f6c5de94..91dde0b815 100644 --- a/lib/system/sets.nim +++ b/lib/system/sets.nim @@ -22,7 +22,7 @@ proc countBits64(n: int64): int {.compilerproc.} = result = countBits32(toU32(n and 0xffffffff'i64)) + countBits32(toU32(n shr 32'i64)) -proc cardSet(s: NimSet, len: int): int {.compilerproc.} = - result = 0 - for i in countup(0, len-1): +proc cardSet(s: NimSet, len: int): int {.compilerproc, inline.} = + for i in 0.. Date: Sun, 10 Feb 2019 04:53:38 -0300 Subject: [PATCH 15/50] Fixes #10357 (#10618) --- lib/pure/httpclient.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim index e5c0c6ac46..7cae865806 100644 --- a/lib/pure/httpclient.nim +++ b/lib/pure/httpclient.nim @@ -551,7 +551,7 @@ type headers*: HttpHeaders ## Headers to send in requests. maxRedirects: int userAgent: string - timeout: int ## Only used for blocking HttpClient for now. + timeout*: int ## Only used for blocking HttpClient for now. proxy: Proxy ## ``nil`` or the callback to call when request progress changes. when SocketType is Socket: From d46a590f7463a44865f0ec4129a3ddee219ede36 Mon Sep 17 00:00:00 2001 From: Dean Thompson Date: Sun, 10 Feb 2019 02:56:28 -0500 Subject: [PATCH 16/50] Expanded the typeinfo module's doc comment to warn that rtti will evolve and suggest alternative approaches. (#10596) --- lib/core/typeinfo.nim | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/core/typeinfo.nim b/lib/core/typeinfo.nim index cfb8f8f5d7..32fedd0c1e 100644 --- a/lib/core/typeinfo.nim +++ b/lib/core/typeinfo.nim @@ -8,12 +8,19 @@ # ## This module implements an interface to Nim's `runtime type information`:idx: -## (`RTTI`:idx:). -## Note that even though ``Any`` and its operations hide the nasty low level -## details from its clients, it remains inherently unsafe! +## (`RTTI`:idx:). See the `marshal `_ module for an example of +## what this module allows you to do. ## -## See the `marshal `_ module for what this module allows you -## to do. +## Note that even though ``Any`` and its operations hide the nasty low level +## details from its clients, it remains inherently unsafe! Also, Nim's +## runtime type information will evolve and may eventually be deprecated. +## As an alternative approach to programmatically understanding and +## manipulating types, consider using the `macros `_ package to +## work with the types' AST representation at compile time. See, for example, +## the `getTypeImpl proc`_. As an alternative +## approach to storing arbitrary types at runtime, consider using generics. +## +## {.push hints: off.} From a9b2e83daa7c1cb1fbf1cab0a6b33ad27b36c7ff Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sun, 10 Feb 2019 15:49:11 +0100 Subject: [PATCH 17/50] Use standard XML escaping --- lib/pure/xmltree.nim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/pure/xmltree.nim b/lib/pure/xmltree.nim index e1d24ea420..2564c4465c 100644 --- a/lib/pure/xmltree.nim +++ b/lib/pure/xmltree.nim @@ -492,8 +492,7 @@ proc addEscaped*(result: var string, s: string) = of '>': result.add(">") of '&': result.add("&") of '"': result.add(""") - of '\'': result.add("'") - of '/': result.add("/") + of '\'': result.add("'") else: result.add(c) proc escape*(s: string): string = @@ -508,8 +507,7 @@ proc escape*(s: string): string = ## ``>`` ``>`` ## ``&`` ``&`` ## ``"`` ``"`` - ## ``'`` ``'`` - ## ``/`` ``/`` + ## ``'`` ``'`` ## ------------ ------------------- ## ## You can also use `addEscaped proc <#addEscaped,string,string>`_. From f0e6becc235c15709ef84598f52c765687941056 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 10 Feb 2019 17:03:16 +0100 Subject: [PATCH 18/50] fixes #10547 --- compiler/vm.nim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/vm.nim b/compiler/vm.nim index f855da0cc1..fd1df3ce90 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -1429,7 +1429,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = of opcNGetType: let rb = instr.regB let rc = instr.regC - case rc: + case rc of 0: # getType opcode: ensureKind(rkNode) @@ -1471,7 +1471,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = createStr regs[ra] let a = regs[rb].node case a.kind - of {nkStrLit..nkTripleStrLit}: + of nkStrLit..nkTripleStrLit: regs[ra].node.strVal = a.strVal of nkCommentStmt: regs[ra].node.strVal = a.comment @@ -1573,7 +1573,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = var bStrVal: cstring = nil # extract strVal from argument ``a`` case aNode.kind - of {nkStrLit..nkTripleStrLit}: + of nkStrLit..nkTripleStrLit: aStrVal = aNode.strVal.cstring of nkIdent: aStrVal = aNode.ident.s.cstring @@ -1585,7 +1585,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = discard # extract strVal from argument ``b`` case bNode.kind - of {nkStrLit..nkTripleStrLit}: + of nkStrLit..nkTripleStrLit: bStrVal = bNode.strVal.cstring of nkIdent: bStrVal = bNode.ident.s.cstring @@ -1598,7 +1598,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = # set result regs[ra].intVal = if aStrVal != nil and bStrVal != nil: - ord(idents.cmpIgnoreStyle(aStrVal,bStrVal,high(int)) == 0) + ord(idents.cmpIgnoreStyle(aStrVal, bStrVal, high(int)) == 0) else: 0 @@ -1948,6 +1948,7 @@ const evalPass* = makePass(myOpen, myProcess, myClose) proc evalConstExprAux(module: PSym; g: ModuleGraph; prc: PSym, n: PNode, mode: TEvalMode): PNode = + if g.config.errorCounter > 0: return n let n = transformExpr(g, module, n, noDestructors = true) setupGlobalCtx(module, g) var c = PCtx g.vm From 352b52a0c9f24ec82b2573a78cd65c0c19b6d29f Mon Sep 17 00:00:00 2001 From: Federico Ceratto Date: Sun, 10 Feb 2019 19:52:13 +0000 Subject: [PATCH 19/50] Add note on channel usage with spawn (#10627) [ci skip] --- lib/system/channels.nim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/system/channels.nim b/lib/system/channels.nim index 14d3a30055..057ea28436 100644 --- a/lib/system/channels.nim +++ b/lib/system/channels.nim @@ -7,12 +7,17 @@ # distribution, for details about the copyright. # -## Channel support for threads. **Note**: This is part of the system module. -## Do not import it directly. To activate thread support you need to compile -## with the ``--threads:on`` command line switch. +## Channel support for threads. +## +## **Note**: This is part of the system module. Do not import it directly. +## To activate thread support compile with the ``--threads:on`` command line switch. +## +## **Note:** Channels are designed for the ``Thread`` type. They are unstable when +## used with ``spawn`` ## ## **Note:** The current implementation of message passing does ## not work with cyclic data structures. +## ## **Note:** Channels cannot be passed between threads. Use globals or pass ## them by `ptr`. From 491060839473fbe5fa17b4fd37b93f5dcc662db8 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Sun, 10 Feb 2019 13:07:11 -0800 Subject: [PATCH 20/50] revive #10228 (fix #9880) (#10610) * Make index out of bounds more useful by including the 'bounds'. * fixes #9880 index out of bounds (remaining cases); revives #10228 * change err msg to: `index 3 not in 0 .. 1` --- compiler/semfold.nim | 4 +-- compiler/vm.nim | 22 +++++++-------- lib/core/typeinfo.nim | 10 ++++--- lib/pure/collections/sharedstrings.nim | 2 +- lib/pure/os.nim | 6 ++-- lib/system/indexerrors.nim | 4 +-- lib/system/jssys.nim | 8 ++++-- tests/exception/testindexerroroutput.nims | 23 +++++++++++++++ tests/exception/tindexerrorformatbounds.nim | 31 +++++++++++++++++++++ tests/misc/tinvalidarrayaccess.nim | 6 ++-- tests/misc/tinvalidarrayaccess2.nim | 8 +----- 11 files changed, 88 insertions(+), 36 deletions(-) create mode 100644 tests/exception/testindexerroroutput.nims create mode 100644 tests/exception/tindexerrorformatbounds.nim diff --git a/compiler/semfold.nim b/compiler/semfold.nim index 237a5127a9..f0b03018fb 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -493,11 +493,11 @@ proc foldArrayAccess(m: PSym, n: PNode; g: ModuleGraph): PNode = result = x.sons[int(idx)] if result.kind == nkExprColonExpr: result = result.sons[1] else: - localError(g.config, n.info, formatErrorIndexBound(idx, sonsLen(x)+1) & $n) + localError(g.config, n.info, formatErrorIndexBound(idx, sonsLen(x)-1) & $n) of nkBracket: idx = idx - firstOrd(g.config, x.typ) if idx >= 0 and idx < x.len: result = x.sons[int(idx)] - else: localError(g.config, n.info, formatErrorIndexBound(idx, x.len+1) & $n) + else: localError(g.config, n.info, formatErrorIndexBound(idx, x.len-1) & $n) of nkStrLit..nkTripleStrLit: result = newNodeIT(nkCharLit, x.info, n.typ) if idx >= 0 and idx < len(x.strVal): diff --git a/compiler/vm.nim b/compiler/vm.nim index fd1df3ce90..74f2a367dc 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -11,6 +11,7 @@ ## An instruction is 1-3 int32s in memory, it is a register based VM. import ast except getstr +import system/indexerrors import strutils, astalgo, msgs, vmdef, vmgen, nimsets, types, passes, @@ -473,7 +474,6 @@ proc setLenSeq(c: PCtx; node: PNode; newLen: int; info: TLineInfo) = node.sons[i] = getNullValue(typ.sons[0], info, c.config) const - errIndexOutOfBounds = "index out of bounds" errNilAccess = "attempt to access a nil address" errOverOrUnderflow = "over- or underflow" errConstantDivisionByZero = "division by zero" @@ -577,7 +577,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = # a = b[c] decodeBC(rkNode) if regs[rc].intVal > high(int): - stackTrace(c, tos, pc, errIndexOutOfBounds) + stackTrace(c, tos, pc, formatErrorIndexBound(regs[rc].intVal, high(int))) let idx = regs[rc].intVal.int let src = regs[rb].node if src.kind in {nkStrLit..nkTripleStrLit}: @@ -585,11 +585,11 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = regs[ra].node = newNodeI(nkCharLit, c.debug[pc]) regs[ra].node.intVal = src.strVal[idx].ord else: - stackTrace(c, tos, pc, errIndexOutOfBounds) + stackTrace(c, tos, pc, formatErrorIndexBound(idx, src.strVal.len-1)) elif src.kind notin {nkEmpty..nkFloat128Lit} and idx <% src.len: regs[ra].node = src.sons[idx] else: - stackTrace(c, tos, pc, errIndexOutOfBounds) + stackTrace(c, tos, pc, formatErrorIndexBound(idx, src.len-1)) of opcLdStrIdx: decodeBC(rkInt) let idx = regs[rc].intVal.int @@ -599,7 +599,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = elif idx == s.len and optLaxStrings in c.config.options: regs[ra].intVal = 0 else: - stackTrace(c, tos, pc, errIndexOutOfBounds) + stackTrace(c, tos, pc, formatErrorIndexBound(idx, s.len-1)) of opcWrArr: # a[b] = c decodeBC(rkNode) @@ -609,11 +609,11 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = if idx <% arr.strVal.len: arr.strVal[idx] = chr(regs[rc].intVal) else: - stackTrace(c, tos, pc, errIndexOutOfBounds) + stackTrace(c, tos, pc, formatErrorIndexBound(idx, arr.strVal.len-1)) elif idx <% arr.len: writeField(arr.sons[idx], regs[rc]) else: - stackTrace(c, tos, pc, errIndexOutOfBounds) + stackTrace(c, tos, pc, formatErrorIndexBound(idx, arr.len-1)) of opcLdObj: # a = b.c decodeBC(rkNode) @@ -644,7 +644,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = if idx <% regs[ra].node.strVal.len: regs[ra].node.strVal[idx] = chr(regs[rc].intVal) else: - stackTrace(c, tos, pc, errIndexOutOfBounds) + stackTrace(c, tos, pc, formatErrorIndexBound(idx, regs[ra].node.strVal.len-1)) of opcAddrReg: decodeB(rkRegisterAddr) regs[ra].regAddr = addr(regs[rb]) @@ -1361,7 +1361,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = if src.kind notin {nkEmpty..nkNilLit} and idx <% src.len: regs[ra].node = src.sons[idx] else: - stackTrace(c, tos, pc, errIndexOutOfBounds) + stackTrace(c, tos, pc, formatErrorIndexBound(idx, src.len-1)) of opcNSetChild: decodeBC(rkNode) let idx = regs[rb].intVal.int @@ -1369,7 +1369,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = if dest.kind notin {nkEmpty..nkNilLit} and idx <% dest.len: dest.sons[idx] = regs[rc].node else: - stackTrace(c, tos, pc, errIndexOutOfBounds) + stackTrace(c, tos, pc, formatErrorIndexBound(idx, dest.len-1)) of opcNAdd: decodeBC(rkNode) var u = regs[rb].node @@ -1774,7 +1774,7 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = if contains(g.cacheSeqs, destKey) and idx <% g.cacheSeqs[destKey].len: regs[ra].node = g.cacheSeqs[destKey][idx.int] else: - stackTrace(c, tos, pc, errIndexOutOfBounds) + stackTrace(c, tos, pc, formatErrorIndexBound(idx, g.cacheSeqs[destKey].len-1)) of opcNctPut: let g = c.graph let destKey = regs[ra].node.strVal diff --git a/lib/core/typeinfo.nim b/lib/core/typeinfo.nim index 32fedd0c1e..d6dd16b54c 100644 --- a/lib/core/typeinfo.nim +++ b/lib/core/typeinfo.nim @@ -27,6 +27,8 @@ include "system/inclrtl.nim" include "system/hti.nim" +import system/indexerrors + {.pop.} type @@ -201,14 +203,14 @@ proc `[]`*(x: Any, i: int): Any = of tyArray: var bs = x.rawType.base.size if i >=% x.rawType.size div bs: - raise newException(IndexError, "index out of bounds") + raise newException(IndexError, formatErrorIndexBound(i, x.rawType.size div bs)) return newAny(x.value +!! i*bs, x.rawType.base) of tySequence: var s = cast[ppointer](x.value)[] if s == nil: raise newException(ValueError, "sequence is nil") var bs = x.rawType.base.size if i >=% cast[PGenSeq](s).len: - raise newException(IndexError, "index out of bounds") + raise newException(IndexError, formatErrorIndexBound(i, cast[PGenSeq](s).len-1)) return newAny(s +!! (GenericSeqSize+i*bs), x.rawType.base) else: assert false @@ -218,7 +220,7 @@ proc `[]=`*(x: Any, i: int, y: Any) = of tyArray: var bs = x.rawType.base.size if i >=% x.rawType.size div bs: - raise newException(IndexError, "index out of bounds") + raise newException(IndexError, formatErrorIndexBound(i, x.rawType.size div bs)) assert y.rawType == x.rawType.base genericAssign(x.value +!! i*bs, y.value, y.rawType) of tySequence: @@ -226,7 +228,7 @@ proc `[]=`*(x: Any, i: int, y: Any) = if s == nil: raise newException(ValueError, "sequence is nil") var bs = x.rawType.base.size if i >=% cast[PGenSeq](s).len: - raise newException(IndexError, "index out of bounds") + raise newException(IndexError, formatErrorIndexBound(i, cast[PGenSeq](s).len-1)) assert y.rawType == x.rawType.base genericAssign(s +!! (GenericSeqSize+i*bs), y.value, y.rawType) else: assert false diff --git a/lib/pure/collections/sharedstrings.nim b/lib/pure/collections/sharedstrings.nim index b283cd4b10..ca52ec63c4 100644 --- a/lib/pure/collections/sharedstrings.nim +++ b/lib/pure/collections/sharedstrings.nim @@ -12,7 +12,7 @@ type UncheckedCharArray = UncheckedArray[char] -import system/helpers2 +import system/indexerrors type Buffer = ptr object diff --git a/lib/pure/os.nim b/lib/pure/os.nim index e88c3c6e8c..0b9c8babc8 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -47,7 +47,7 @@ include "system/inclrtl" import - strutils, pathnorm + strutils, pathnorm, system/indexerrors const weirdTarget = defined(nimscript) or defined(js) @@ -2551,7 +2551,7 @@ elif defined(windows): ownArgv = parseCmdLine($getCommandLine()) ownParsedArgv = true if i < ownArgv.len and i >= 0: return TaintedString(ownArgv[i]) - raise newException(IndexError, "invalid index") + raise newException(IndexError, formatErrorIndexBound(i, ownArgv.len-1)) elif defined(genode): proc paramStr*(i: int): TaintedString = @@ -2570,7 +2570,7 @@ elif not defined(createNimRtl) and proc paramStr*(i: int): TaintedString {.tags: [ReadIOEffect].} = # Docstring in nimdoc block. if i < cmdCount and i >= 0: return TaintedString($cmdLine[i]) - raise newException(IndexError, "invalid index") + raise newException(IndexError, formatErrorIndexBound(i, cmdCount-1)) proc paramCount*(): int {.tags: [ReadIOEffect].} = # Docstring in nimdoc block. diff --git a/lib/system/indexerrors.nim b/lib/system/indexerrors.nim index 8bd69ad711..cb1d522c97 100644 --- a/lib/system/indexerrors.nim +++ b/lib/system/indexerrors.nim @@ -1,7 +1,7 @@ # imported by other modules, unlike helpers.nim which is included template formatErrorIndexBound*[T](i, a, b: T): string = - "index out of bounds: (a: " & $a & ") <= (i: " & $i & ") <= (b: " & $b & ") " + "index " & $i & " not in " & $a & " .. " & $b template formatErrorIndexBound*[T](i, n: T): string = - "index out of bounds: (i: " & $i & ") <= (n: " & $n & ") " + formatErrorIndexBound(i, 0, n) diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index d7718e4f4e..27dd9b0209 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -7,6 +7,8 @@ # distribution, for details about the copyright. # +import system/indexerrors + proc log*(s: cstring) {.importc: "console.log", varargs, nodecl.} type @@ -157,8 +159,8 @@ proc raiseDivByZero {.exportc: "raiseDivByZero", noreturn, compilerProc.} = proc raiseRangeError() {.compilerproc, noreturn.} = raise newException(RangeError, "value out of range") -proc raiseIndexError() {.compilerproc, noreturn.} = - raise newException(IndexError, "index out of bounds") +proc raiseIndexError(i, a, b: int) {.compilerproc, noreturn.} = + raise newException(IndexError, formatErrorIndexBound(int(i), int(a), int(b))) proc raiseFieldError(f: string) {.compilerproc, noreturn.} = raise newException(FieldError, f & " is not accessible") @@ -626,7 +628,7 @@ proc arrayConstr(len: int, value: JSRef, typ: PNimType): JSRef {. proc chckIndx(i, a, b: int): int {.compilerproc.} = if i >= a and i <= b: return i - else: raiseIndexError() + else: raiseIndexError(i, a, b) proc chckRange(i, a, b: int): int {.compilerproc.} = if i >= a and i <= b: return i diff --git a/tests/exception/testindexerroroutput.nims b/tests/exception/testindexerroroutput.nims new file mode 100644 index 0000000000..e282f14b41 --- /dev/null +++ b/tests/exception/testindexerroroutput.nims @@ -0,0 +1,23 @@ +mode = ScriptMode.Verbose + +case paramStr(3): + of "test1": + #543 + block: + let s = "abc" + discard s[len(s)] + of "test2": + #537 + block: + var s = "abc" + s[len(s)] = 'd' + of "test3": + #588 + block: + let arr = ['a', 'b', 'c'] + discard arr[len(arr)] + of "test4": + #588 + block: + var arr = ['a', 'b', 'c'] + arr[len(arr)] = 'd' diff --git a/tests/exception/tindexerrorformatbounds.nim b/tests/exception/tindexerrorformatbounds.nim new file mode 100644 index 0000000000..7563c5ffa8 --- /dev/null +++ b/tests/exception/tindexerrorformatbounds.nim @@ -0,0 +1,31 @@ +import os, osproc, strutils + +const characters = "abcdefghijklmnopqrstuvwxyz" +var s: string + +# # chcks.nim:23 +# # test formatErrorIndexBound returns correct bounds +block: + s = characters + try: + discard s[0..999] + except IndexError: + let msg = getCurrentExceptionMsg() + let expected = "index $# not in 0 .. $#" % [$len(s), $(len(s)-1)] + doAssert msg.contains expected, $(msg, expected) + +block: + try: + discard paramStr(999) + except IndexError: + let msg = getCurrentExceptionMsg() + let expected = "index 999 not in 0 .. 0" + doAssert msg.contains expected, $(msg, expected) + +block: + const nim = getCurrentCompilerExe() + for i in 1..4: + let (outp, errC) = execCmdEx("$# e tests/exception/testindexerroroutput.nims test$#" % [nim, $i]) + let expected = "index 3 not in 0 .. 2" + doAssert errC != 0 + doAssert outp.contains expected, $(outp, errC, expected, i) diff --git a/tests/misc/tinvalidarrayaccess.nim b/tests/misc/tinvalidarrayaccess.nim index ab44d98e88..f8bce45ef3 100644 --- a/tests/misc/tinvalidarrayaccess.nim +++ b/tests/misc/tinvalidarrayaccess.nim @@ -1,14 +1,14 @@ discard """ - errormsg: "index out of bounds: (a: 0) <= (i: 2) <= (b: 1) " + errormsg: "index 2 not in 0 .. 1" line: 18 """ - block: try: let a = @[1,2] echo a[3] except Exception as e: - doAssert e.msg == "index out of bounds: (i:3) <= (n:1) " + doAssert e.msg == "index 3 not in 0 .. 1" + # note: this is not being tested, because the CT error happens before block: type TTestArr = array[0..1, int16] diff --git a/tests/misc/tinvalidarrayaccess2.nim b/tests/misc/tinvalidarrayaccess2.nim index a791dc4e7f..0a07038344 100644 --- a/tests/misc/tinvalidarrayaccess2.nim +++ b/tests/misc/tinvalidarrayaccess2.nim @@ -1,5 +1,5 @@ discard """ - errormsg: "index out of bounds: (a: 0) <= (i: 3) <= (b: 1) " + errormsg: "index 3 not in 0 .. 1" line: 9 """ @@ -8,9 +8,3 @@ discard """ let a = [1,2] echo a[3] -when false: - # TOOD: this case is not yet handled, giving: "index out of bounds" - proc fun()= - let a = @[1,2] - echo a[3] - static: fun() From 5fd9bf9cd52a19b0ddd59452d9ebde0715d7d890 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sun, 10 Feb 2019 22:07:51 +0100 Subject: [PATCH 21/50] Propagate tfGcSafe flag to generic instantiations (#10620) Fixes a nasty endless loop in the generic instantiation phase. --- compiler/semtypinst.nim | 5 ++--- tests/generics/tgenerics_various.nim | 11 +++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index ebe822cdfc..ceabd8e60d 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -300,7 +300,6 @@ proc instCopyType*(cl: var TReplTypeVars, t: PType): PType = proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType = # tyGenericInvocation[A, tyGenericInvocation[A, B]] # is difficult to handle: - const eqFlags = eqTypeFlags + {tfGcSafe} var body = t.sons[0] if body.kind != tyGenericBody: internalError(cl.c.config, cl.info, "no generic body") @@ -311,7 +310,7 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType = else: result = searchInstTypes(t) - if result != nil and eqFlags*result.flags == eqFlags*t.flags: + if result != nil and sameFlags(result, t): when defined(reportCacheHits): echo "Generic instantiation cached ", typeToString(result), " for ", typeToString(t) return @@ -329,7 +328,7 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType = if header != t: # search again after first pass: result = searchInstTypes(header) - if result != nil and eqFlags*result.flags == eqFlags*t.flags: + if result != nil and sameFlags(result, t): when defined(reportCacheHits): echo "Generic instantiation cached ", typeToString(result), " for ", typeToString(t), " header ", typeToString(header) diff --git a/tests/generics/tgenerics_various.nim b/tests/generics/tgenerics_various.nim index 9e61865340..656bfa566e 100644 --- a/tests/generics/tgenerics_various.nim +++ b/tests/generics/tgenerics_various.nim @@ -242,3 +242,14 @@ block tvarargs_vs_generics: withDirectType "string" withOpenArray "string" withVarargs "string" + +block: + type + Que[T] {.gcsafe.} = object + x: T + + proc `=`[T](q: var Que[T]; x: Que[T]) = + discard + + var x: Que[int] + doAssert(x.x == 0) From 305f6052eee529be8c5db0c8caebee6823262674 Mon Sep 17 00:00:00 2001 From: Jjp137 Date: Sun, 10 Feb 2019 23:50:31 -0800 Subject: [PATCH 22/50] better docs: random (#10546) --- lib/pure/random.nim | 487 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 422 insertions(+), 65 deletions(-) diff --git a/lib/pure/random.nim b/lib/pure/random.nim index 378ca6f87b..85466ed9ef 100644 --- a/lib/pure/random.nim +++ b/lib/pure/random.nim @@ -7,12 +7,76 @@ # distribution, for details about the copyright. # -## Nim's standard random number generator. Based on -## the ``xoroshiro128+`` (xor/rotate/shift/rotate) library. +## Nim's standard random number generator. +## +## Its implementation is based on the ``xoroshiro128+`` +## (xor/rotate/shift/rotate) library. ## * More information: http://xoroshiro.di.unimi.it/ ## * C implementation: http://xoroshiro.di.unimi.it/xoroshiro128plus.c ## ## **Do not use this module for cryptographic purposes!** +## +## Basic usage +## =========== +## +## To get started, here are some examples: +## +## .. code-block:: +## +## import random +## +## # Call randomize() once to initialize the default random number generator +## # If this is not called, the same results will occur every time these +## # examples are run +## randomize() +## +## # Pick a number between 0 and 100 +## let num = rand(100) +## echo num +## +## # Roll a six-sided die +## let roll = rand(1..6) +## echo roll +## +## # Pick a marble from a bag +## let marbles = ["red", "blue", "green", "yellow", "purple"] +## let pick = sample(marbles) +## echo pick +## +## # Shuffle some cards +## var cards = ["Ace", "King", "Queen", "Jack", "Ten"] +## shuffle(cards) +## echo cards +## +## These examples all use the default random number generator. The +## `Rand type<#Rand>`_ represents the state of a random number generator. +## For convenience, this module contains a default Rand state that corresponds +## to the default random number generator. Most procs in this module which do +## not take in a Rand parameter, including those called in the above examples, +## use the default generator. Those procs are **not** thread-safe. +## +## Note that the default generator always starts in the same state. +## The `randomize proc<#randomize>`_ can be called to initialize the default +## generator with a seed based on the current time, and it only needs to be +## called once before the first usage of procs from this module. If +## ``randomize`` is not called, then the default generator will always produce +## the same results. +## +## Generators that are independent of the default one can be created with the +## `initRand proc<#initRand,int64>`_. +## +## Again, it is important to remember that this module must **not** be used for +## cryptographic applications. +## +## See also +## ======== +## * `math module`_ for basic math routines +## * `mersenne module`_ for the Mersenne Twister random number +## generator +## * `stats module`_ for statistical analysis +## * `list of cryptographic and hashing modules +## `_ +## in the standard library import algorithm #For upperBound @@ -29,9 +93,19 @@ else: const randMax = 18_446_744_073_709_551_615u64 type - Rand* = object ## State of the random number generator. - ## The procs that use the default state - ## are **not** thread-safe! + Rand* = object ## State of a random number generator. + ## + ## Create a new Rand state using the `initRand proc<#initRand,int64>`_. + ## + ## The module contains a default Rand state for convenience. + ## It corresponds to the default random number generator's state. + ## The default Rand state always starts with the same values, but the + ## `randomize proc<#randomize>`_ can be used to seed the default generator + ## with a value based on the current time. + ## + ## Many procs have two variations: one that takes in a Rand parameter and + ## another that uses the default generator. The procs that use the default + ## generator are **not** thread-safe! a0, a1: ui when defined(JS): @@ -48,7 +122,20 @@ proc rotl(x, k: ui): ui = result = (x shl k) or (x shr (ui(64) - k)) proc next*(r: var Rand): uint64 = - ## Uses the state to compute a new ``uint64`` random number. + ## Computes a random ``uint64`` number using the given state. + ## + ## See also: + ## * `rand proc<#rand,Rand,Natural>`_ that returns an integer between zero and + ## a given upper bound + ## * `rand proc<#rand,Rand,range[]>`_ that returns a float + ## * `rand proc<#rand,Rand,HSlice[T,T]>`_ that accepts a slice + ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer type + ## * `skipRandomNumbers proc<#skipRandomNumbers,Rand>`_ + runnableExamples: + var r = initRand(2019) + doAssert r.next() == 138_744_656_611_299'u64 + doAssert r.next() == 979_810_537_855_049_344'u64 + doAssert r.next() == 3_628_232_584_225_300_704'u64 let s0 = r.a0 var s1 = r.a1 result = s0 + s1 @@ -57,9 +144,52 @@ proc next*(r: var Rand): uint64 = r.a1 = rotl(s1, 36) # c proc skipRandomNumbers*(s: var Rand) = - ## This is the jump function for the generator. It is equivalent - ## to 2^64 calls to next(); it can be used to generate 2^64 - ## non-overlapping subsequences for parallel computations. + ## The jump function for the generator. + ## + ## This proc is equivalent to 2^64 calls to `next<#next,Rand>`_, and it can + ## be used to generate 2^64 non-overlapping subsequences for parallel + ## computations. + ## + ## When multiple threads are generating random numbers, each thread must + ## own the `Rand<#Rand>`_ state it is using so that the thread can safely + ## obtain random numbers. However, if each thread creates its own Rand state, + ## the subsequences of random numbers that each thread generates may overlap, + ## even if the provided seeds are unique. This is more likely to happen as the + ## number of threads and amount of random numbers generated increases. + ## + ## If many threads will generate random numbers concurrently, it is better to + ## create a single Rand state and pass it to each thread. After passing the + ## Rand state to a thread, call this proc before passing it to the next one. + ## By using the Rand state this way, the subsequences of random numbers + ## generated in each thread will never overlap as long as no thread generates + ## more than 2^64 random numbers. + ## + ## The following example below demonstrates this pattern: + ## + ## .. code-block:: + ## # Compile this example with --threads:on + ## import random + ## import threadpool + ## + ## const spawns = 4 + ## const numbers = 100000 + ## + ## proc randomSum(rand: Rand): int = + ## var r = rand + ## for i in 1..numbers: + ## result += rand(1..10) + ## + ## var r = initRand(2019) + ## var vals: array[spawns, FlowVar[int]] + ## for val in vals.mitems: + ## val = spawn(randomSum(r)) + ## r.skipRandomNumbers() + ## + ## for val in vals: + ## echo ^val + ## + ## See also: + ## * `next proc<#next,Rand>`_ when defined(JS): const helper = [0xbeac0467u32, 0xd86b048bu32] else: @@ -77,22 +207,16 @@ proc skipRandomNumbers*(s: var Rand) = s.a1 = s1 proc random*(max: int): int {.benign, deprecated.} = - ## Returns a random number in the range 0..max-1. The sequence of - ## random number is always the same, unless `randomize` is called - ## which initializes the random number generator with a "random" - ## number, i.e. a tickcount. **Deprecated since version 0.18.0**. - ## Use ``rand`` instead. + ## **Deprecated since version 0.18.0:** + ## Use `rand(int)<#rand,int>`_ instead. while true: let x = next(state) if x < randMax - (randMax mod ui(max)): return int(x mod uint64(max)) proc random*(max: float): float {.benign, deprecated.} = - ## Returns a random number in the range 0..`_ instead. let x = next(state) when defined(JS): result = (float(x) / float(high(uint32))) * max @@ -101,22 +225,29 @@ proc random*(max: float): float {.benign, deprecated.} = result = (cast[float](u) - 1.0) * max proc random*[T](x: HSlice[T, T]): T {.deprecated.} = - ## For a slice `a .. b` returns a value in the range `a .. b-1`. - ## **Deprecated since version 0.18.0**. - ## Use ``rand`` instead. + ## **Deprecated since version 0.18.0:** + ## Use `rand[T](HSlice[T, T])<#rand,HSlice[T,T]>`_ instead. result = T(random(x.b - x.a)) + x.a proc random*[T](a: openArray[T]): T {.deprecated.} = - ## returns a random element from the openarray `a`. - ## **Deprecated since version 0.18.0**. - ## Use ``rand`` instead. + ## **Deprecated since version 0.18.0:** + ## Use `sample[T](openArray[T])<#sample,openArray[T]>`_ instead. result = a[random(a.low..a.len)] proc rand*(r: var Rand; max: Natural): int {.benign.} = - ## Returns a random number in the range 0..max. The sequence of - ## random number is always the same, unless `randomize` is called - ## which initializes the random number generator with a "random" - ## number, i.e. a tickcount. + ## Returns a random integer in the range `0..max` using the given state. + ## + ## See also: + ## * `rand proc<#rand,int>`_ that returns an integer using the default + ## random number generator + ## * `rand proc<#rand,Rand,range[]>`_ that returns a float + ## * `rand proc<#rand,Rand,HSlice[T,T]>`_ that accepts a slice + ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer type + runnableExamples: + var r = initRand(123) + doAssert r.rand(100) == 0 + doAssert r.rand(100) == 96 + doAssert r.rand(100) == 66 if max == 0: return while true: let x = next(r) @@ -124,17 +255,41 @@ proc rand*(r: var Rand; max: Natural): int {.benign.} = return int(x mod (uint64(max)+1u64)) proc rand*(max: int): int {.benign.} = - ## Returns a random number in the range 0..max. The sequence of - ## random number is always the same, unless `randomize` is called - ## which initializes the random number generator with a "random" - ## number, i.e. a tickcount. + ## Returns a random integer in the range `0..max`. + ## + ## If `randomize<#randomize>`_ has not been called, the sequence of random + ## numbers returned from this proc will always be the same. + ## + ## This proc uses the default random number generator. Thus, it is **not** + ## thread-safe. + ## + ## See also: + ## * `rand proc<#rand,Rand,Natural>`_ that returns an integer using a + ## provided state + ## * `rand proc<#rand,float>`_ that returns a float + ## * `rand proc<#rand,HSlice[T,T]>`_ that accepts a slice + ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer type + runnableExamples: + randomize(123) + doAssert rand(100) == 0 + doAssert rand(100) == 96 + doAssert rand(100) == 66 rand(state, max) proc rand*(r: var Rand; max: range[0.0 .. high(float)]): float {.benign.} = - ## Returns a random number in the range 0..max. The sequence of - ## random number is always the same, unless `randomize` is called - ## which initializes the random number generator with a "random" - ## number, i.e. a tickcount. + ## Returns a random floating point number in the range `0.0..max` + ## using the given state. + ## + ## See also: + ## * `rand proc<#rand,float>`_ that returns a float using the default + ## random number generator + ## * `rand proc<#rand,Rand,Natural>`_ that returns an integer + ## * `rand proc<#rand,Rand,HSlice[T,T]>`_ that accepts a slice + ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer type + runnableExamples: + var r = initRand(234) + let f = r.rand(1.0) + ## f = 8.717181376738381e-07 let x = next(r) when defined(JS): result = (float(x) / float(high(uint32))) * max @@ -143,51 +298,162 @@ proc rand*(r: var Rand; max: range[0.0 .. high(float)]): float {.benign.} = result = (cast[float](u) - 1.0) * max proc rand*(max: float): float {.benign.} = - ## Returns a random number in the range 0..max. The sequence of - ## random number is always the same, unless `randomize` is called - ## which initializes the random number generator with a "random" - ## number, i.e. a tickcount. + ## Returns a random floating point number in the range `0.0..max`. + ## + ## If `randomize<#randomize>`_ has not been called, the sequence of random + ## numbers returned from this proc will always be the same. + ## + ## This proc uses the default random number generator. Thus, it is **not** + ## thread-safe. + ## + ## See also: + ## * `rand proc<#rand,Rand,range[]>`_ that returns a float using a + ## provided state + ## * `rand proc<#rand,int>`_ that returns an integer + ## * `rand proc<#rand,HSlice[T,T]>`_ that accepts a slice + ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer type + runnableExamples: + randomize(234) + let f = rand(1.0) + ## f = 8.717181376738381e-07 rand(state, max) proc rand*[T](r: var Rand; x: HSlice[T, T]): T = - ## For a slice `a .. b` returns a value in the range `a .. b`. + ## For a slice `a..b`, returns a value in the range `a..b` using the given + ## state. + ## + ## See also: + ## * `rand proc<#rand,HSlice[T,T]>`_ that accepts a slice and uses the + ## default random number generator + ## * `rand proc<#rand,Rand,Natural>`_ that returns an integer + ## * `rand proc<#rand,Rand,range[]>`_ that returns a float + ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer type + runnableExamples: + var r = initRand(345) + doAssert r.rand(1..6) == 4 + doAssert r.rand(1..6) == 4 + doAssert r.rand(1..6) == 6 result = T(rand(r, x.b - x.a)) + x.a proc rand*[T](x: HSlice[T, T]): T = - ## For a slice `a .. b` returns a value in the range `a .. b`. + ## For a slice `a..b`, returns a value in the range `a..b`. + ## + ## If `randomize<#randomize>`_ has not been called, the sequence of random + ## numbers returned from this proc will always be the same. + ## + ## This proc uses the default random number generator. Thus, it is **not** + ## thread-safe. + ## + ## See also: + ## * `rand proc<#rand,Rand,HSlice[T,T]>`_ that accepts a slice and uses + ## a provided state + ## * `rand proc<#rand,int>`_ that returns an integer + ## * `rand proc<#rand,float>`_ that returns a floating point number + ## * `rand proc<#rand,typedesc[T]>`_ that accepts an integer type + runnableExamples: + randomize(345) + doAssert rand(1..6) == 4 + doAssert rand(1..6) == 4 + doAssert rand(1..6) == 6 result = rand(state, x) proc rand*[T](r: var Rand; a: openArray[T]): T {.deprecated.} = - ## Returns a random element from the openarray `a`. - ## **Deprecated since v0.20.0:** use ``sample`` instead. + ## **Deprecated since version 0.20.0:** + ## Use `sample[T](Rand, openArray[T])<#sample,Rand,openArray[T]>`_ instead. result = a[rand(r, a.low..a.high)] proc rand*[T: SomeInteger](t: typedesc[T]): T = ## Returns a random integer in the range `low(T)..high(T)`. + ## + ## If `randomize<#randomize>`_ has not been called, the sequence of random + ## numbers returned from this proc will always be the same. + ## + ## This proc uses the default random number generator. Thus, it is **not** + ## thread-safe. + ## + ## See also: + ## * `rand proc<#rand,int>`_ that returns an integer + ## * `rand proc<#rand,float>`_ that returns a floating point number + ## * `rand proc<#rand,HSlice[T,T]>`_ that accepts a slice + runnableExamples: + randomize(567) + doAssert rand(int8) == 55 + doAssert rand(int8) == -42 + doAssert rand(int8) == 43 + doAssert rand(uint32) == 578980729'u32 + doAssert rand(uint32) == 4052940463'u32 + doAssert rand(uint32) == 2163872389'u32 result = cast[T](state.next) proc rand*[T](a: openArray[T]): T {.deprecated.} = - ## returns a random element from the openarray `a`. - ## **Deprecated since v0.20.0:** use ``sample`` instead. + ## **Deprecated since version 0.20.0:** + ## Use `sample[T](openArray[T])<#sample,openArray[T]>`_ instead. result = a[rand(a.low..a.high)] proc sample*[T](r: var Rand; a: openArray[T]): T = - ## returns a random element from openArray ``a`` using state in ``r``. + ## Returns a random element from ``a`` using the given state. + ## + ## See also: + ## * `sample proc<#sample,openArray[T]>`_ that uses the default + ## random number generator + ## * `sample proc<#sample,Rand,openArray[T],openArray[U]>`_ that uses a + ## cumulative distribution function + runnableExamples: + let marbles = ["red", "blue", "green", "yellow", "purple"] + var r = initRand(456) + doAssert r.sample(marbles) == "blue" + doAssert r.sample(marbles) == "yellow" + doAssert r.sample(marbles) == "red" result = a[r.rand(a.low..a.high)] proc sample*[T](a: openArray[T]): T = - ## returns a random element from openArray ``a`` using non-thread-safe state. + ## Returns a random element from ``a``. + ## + ## If `randomize<#randomize>`_ has not been called, the order of outcomes + ## from this proc will always be the same. + ## + ## This proc uses the default random number generator. Thus, it is **not** + ## thread-safe. + ## + ## See also: + ## * `sample proc<#sample,Rand,openArray[T]>`_ that uses a provided state + ## * `sample proc<#sample,openArray[T],openArray[U]>`_ that uses a + ## cumulative distribution function + runnableExamples: + let marbles = ["red", "blue", "green", "yellow", "purple"] + randomize(456) + doAssert sample(marbles) == "blue" + doAssert sample(marbles) == "yellow" + doAssert sample(marbles) == "red" result = a[rand(a.low..a.high)] proc sample*[T, U](r: var Rand; a: openArray[T], cdf: openArray[U]): T = - ## Sample one element from openArray ``a`` when it has cumulative distribution - ## function (CDF) ``cdf`` (not necessarily normalized, any type of elements - ## convertible to ``float``). Uses state in ``r``. E.g.: + ## Returns an element from ``a`` using a cumulative distribution function + ## (CDF) and the given state. ## - ## .. code-block:: nim - ## let val = [ "a", "b", "c", "d" ] # some values - ## var cnt = [1, 2, 3, 4] # histogram of counts - ## echo r.sample(val, cnt.cumsummed) # echo a sample + ## The ``cdf`` argument does not have to be normalized, and it could contain + ## any type of elements that can be converted to a ``float``. It must be + ## the same length as ``a``. Each element in ``cdf`` should be greater than + ## or equal to the previous element. + ## + ## The outcome of the `cumsum`_ proc and the + ## return value of the `cumsummed`_ proc, + ## which are both in the math module, can be used as the ``cdf`` argument. + ## + ## See also: + ## * `sample proc<#sample,openArray[T],openArray[U]>`_ that also utilizes + ## a CDF but uses the default random number generator + ## * `sample proc<#sample,Rand,openArray[T]>`_ that does not use a CDF + runnableExamples: + from math import cumsummed + + let marbles = ["red", "blue", "green", "yellow", "purple"] + let count = [1, 6, 8, 3, 4] + let cdf = count.cumsummed + var r = initRand(789) + doAssert r.sample(marbles, cdf) == "red" + doAssert r.sample(marbles, cdf) == "green" + doAssert r.sample(marbles, cdf) == "blue" assert(cdf.len == a.len) # Two basic sanity checks. assert(float(cdf[^1]) > 0.0) #While we could check cdf[i-1] <= cdf[i] for i in 1..cdf.len, that could get @@ -196,37 +462,128 @@ proc sample*[T, U](r: var Rand; a: openArray[T], cdf: openArray[U]): T = a[cdf.upperBound(U(u))] proc sample*[T, U](a: openArray[T], cdf: openArray[U]): T = - ## Like ``sample(var Rand; openArray[T], openArray[U])``, but uses default - ## non-thread-safe state. + ## Returns an element from ``a`` using a cumulative distribution function + ## (CDF). + ## + ## This proc works similarly to + ## `sample[T, U](Rand, openArray[T], openArray[U]) + ## <#sample,Rand,openArray[T],openArray[U]>`_. + ## See that proc's documentation for more details. + ## + ## If `randomize<#randomize>`_ has not been called, the order of outcomes + ## from this proc will always be the same. + ## + ## This proc uses the default random number generator. Thus, it is **not** + ## thread-safe. + ## + ## See also: + ## * `sample proc<#sample,Rand,openArray[T],openArray[U]>`_ that also utilizes + ## a CDF but uses a provided state + ## * `sample proc<#sample,openArray[T]>`_ that does not use a CDF + runnableExamples: + from math import cumsummed + + let marbles = ["red", "blue", "green", "yellow", "purple"] + let count = [1, 6, 8, 3, 4] + let cdf = count.cumsummed + randomize(789) + doAssert sample(marbles, cdf) == "red" + doAssert sample(marbles, cdf) == "green" + doAssert sample(marbles, cdf) == "blue" state.sample(a, cdf) proc initRand*(seed: int64): Rand = - ## Creates a new ``Rand`` state from ``seed``. + ## Initializes a new `Rand<#Rand>`_ state using the given seed. + ## + ## `seed` must not be zero. Providing a specific seed will produce + ## the same results for that seed each time. + ## + ## The resulting state is independent of the default random number + ## generator's state. + ## + ## See also: + ## * `randomize proc<#randomize,int64>`_ that accepts a seed for the default + ## random number generator + ## * `randomize proc<#randomize>`_ that initializes the default random + ## number generator using the current time + runnableExamples: + from times import getTime, toUnix, nanosecond + + var r1 = initRand(123) + + let now = getTime() + var r2 = initRand(now.toUnix * 1_000_000_000 + now.nanosecond) result.a0 = ui(seed shr 16) result.a1 = ui(seed and 0xffff) discard next(result) proc randomize*(seed: int64) {.benign.} = - ## Initializes the default random number generator - ## with a specific seed. + ## Initializes the default random number generator with the given seed. + ## + ## `seed` must not be zero. Providing a specific seed will produce + ## the same results for that seed each time. + ## + ## See also: + ## * `initRand proc<#initRand,int64>`_ + ## * `randomize proc<#randomize>`_ that uses the current time instead + runnableExamples: + from times import getTime, toUnix, nanosecond + + randomize(123) + + let now = getTime() + randomize(now.toUnix * 1_000_000_000 + now.nanosecond) state = initRand(seed) proc shuffle*[T](r: var Rand; x: var openArray[T]) = - ## Swaps the positions of elements in a sequence randomly. + ## Shuffles a sequence of elements in-place using the given state. + ## + ## See also: + ## * `shuffle proc<#shuffle,openArray[T]>`_ that uses the default + ## random number generator + runnableExamples: + var cards = ["Ace", "King", "Queen", "Jack", "Ten"] + var r = initRand(678) + r.shuffle(cards) + doAssert cards == ["King", "Ace", "Queen", "Ten", "Jack"] for i in countdown(x.high, 1): let j = r.rand(i) swap(x[i], x[j]) proc shuffle*[T](x: var openArray[T]) = - ## Swaps the positions of elements in a sequence randomly. + ## Shuffles a sequence of elements in-place. + ## + ## If `randomize<#randomize>`_ has not been called, the order of outcomes + ## from this proc will always be the same. + ## + ## This proc uses the default random number generator. Thus, it is **not** + ## thread-safe. + ## + ## See also: + ## * `shuffle proc<#shuffle,Rand,openArray[T]>`_ that uses a provided state + runnableExamples: + var cards = ["Ace", "King", "Queen", "Jack", "Ten"] + randomize(678) + shuffle(cards) + doAssert cards == ["King", "Ace", "Queen", "Ten", "Jack"] shuffle(state, x) when not defined(nimscript): import times proc randomize*() {.benign.} = - ## Initializes the random number generator with a "random" - ## number, i.e. a tickcount. Note: Does not work for NimScript. + ## Initializes the default random number generator with a value based on + ## the current time. + ## + ## This proc only needs to be called once, and it should be called before + ## the first usage of procs from this module that use the default random + ## number generator. + ## + ## **Note:** Does not work for NimScript. + ## + ## See also: + ## * `randomize proc<#randomize,int64>`_ that accepts a seed + ## * `initRand proc<#initRand,int64>`_ when defined(js): let time = int64(times.epochTime() * 1_000_000_000) randomize(time) From d3e35c32000b2ed8ff78e55a1d208bbd6d49450b Mon Sep 17 00:00:00 2001 From: narimiran Date: Mon, 11 Feb 2019 09:11:04 +0100 Subject: [PATCH 23/50] macros: add links in the docs [ci skip] --- lib/core/macros.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 8cbcc54dfe..43e61d660a 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -12,6 +12,10 @@ include "system/helpers" ## This module contains the interface to the compiler's abstract syntax ## tree (`AST`:idx:). Macros operate on this tree. +## +## See also: +## * `macros tutorial `_ +## * `macros section in Nim manual `_ ## .. include:: ../../doc/astspec.txt From 6cd3fff093b94aac5378792b169889b7f7959add Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Mon, 11 Feb 2019 07:44:49 -0300 Subject: [PATCH 24/50] Update mimetypes (#10621) * Update mimetypes const mimes, Fix for Nim mimetypes to recognize Nim and Nimble --- lib/pure/mimetypes.nim | 2338 ++++++++++++++++++++++++++++++++-------- 1 file changed, 1863 insertions(+), 475 deletions(-) diff --git a/lib/pure/mimetypes.nim b/lib/pure/mimetypes.nim index 8f5f3a183f..95c51487a5 100644 --- a/lib/pure/mimetypes.nim +++ b/lib/pure/mimetypes.nim @@ -14,481 +14,1869 @@ type mimes: StringTableRef const mimes* = { - "ez": "application/andrew-inset", - "anx": "application/annodex", - "atom": "application/atom+xml", - "atomcat": "application/atomcat+xml", - "atomsrv": "application/atomserv+xml", - "lin": "application/bbolin", - "cap": "application/cap", - "pcap": "application/cap", - "cu": "application/cu-seeme", - "davmount": "application/davmount+xml", - "tsp": "application/dsptype", - "es": "application/ecmascript", - "spl": "application/futuresplash", - "hta": "application/hta", - "jar": "application/java-archive", - "ser": "application/java-serialized-object", - "class": "application/java-vm", - "js": "application/javascript", - "m3g": "application/m3g", - "hqx": "application/mac-binhex40", - "cpt": "application/mac-compactpro", - "nb": "application/mathematica", - "nbp": "application/mathematica", - "mdb": "application/msaccess", - "doc": "application/msword", - "dot": "application/msword", - "mxf": "application/mxf", - "bin": "application/octet-stream", - "oda": "application/oda", - "ogx": "application/ogg", - "pdf": "application/pdf", - "key": "application/pgp-keys", - "pgp": "application/pgp-signature", - "prf": "application/pics-rules", - "ps": "application/postscript", - "ai": "application/postscript", - "eps": "application/postscript", - "epsi": "application/postscript", - "epsf": "application/postscript", - "eps2": "application/postscript", - "eps3": "application/postscript", - "rar": "application/rar", - "rdf": "application/rdf+xml", - "rss": "application/rss+xml", - "rtf": "application/rtf", - "smi": "application/smil", - "smil": "application/smil", - "xhtml": "application/xhtml+xml", - "xht": "application/xhtml+xml", - "xml": "application/xml", - "xsl": "application/xml", - "xsd": "application/xml", - "xspf": "application/xspf+xml", - "zip": "application/zip", - "apk": "application/vnd.android.package-archive", - "cdy": "application/vnd.cinderella", - "kml": "application/vnd.google-earth.kml+xml", - "kmz": "application/vnd.google-earth.kmz", - "xul": "application/vnd.mozilla.xul+xml", - "xls": "application/vnd.ms-excel", - "xlb": "application/vnd.ms-excel", - "xlt": "application/vnd.ms-excel", - "cat": "application/vnd.ms-pki.seccat", - "stl": "application/vnd.ms-pki.stl", - "ppt": "application/vnd.ms-powerpoint", - "pps": "application/vnd.ms-powerpoint", - "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - "xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template", - "pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation", - "ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow", - "potx": "application/vnd.openxmlformats-officedocument.presentationml.template", - "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", - "dotx": "application/vnd.openxmlformats-officedocument.wordprocessingml.template", - "cod": "application/vnd.rim.cod", - "mmf": "application/vnd.smaf", - "sis": "application/vnd.symbian.install", - "vsd": "application/vnd.visio", - "wbxml": "application/vnd.wap.wbxml", - "wmlc": "application/vnd.wap.wmlc", - "wmlsc": "application/vnd.wap.wmlscriptc", - "wpd": "application/vnd.wordperfect", - "wp5": "application/vnd.wordperfect5.1", - "wk": "application/x-123", - "7z": "application/x-7z-compressed", - "abw": "application/x-abiword", - "dmg": "application/x-apple-diskimage", - "bcpio": "application/x-bcpio", - "torrent": "application/x-bittorrent", - "cab": "application/x-cab", - "cbr": "application/x-cbr", - "cbz": "application/x-cbz", - "cdf": "application/x-cdf", - "cda": "application/x-cdf", - "vcd": "application/x-cdlink", - "pgn": "application/x-chess-pgn", - "cpio": "application/x-cpio", - "csh": "application/x-csh", - "deb": "application/x-debian-package", - "udeb": "application/x-debian-package", - "dcr": "application/x-director", - "dir": "application/x-director", - "dxr": "application/x-director", - "dms": "application/x-dms", - "wad": "application/x-doom", - "dvi": "application/x-dvi", - "rhtml": "application/x-httpd-eruby", - "pfa": "application/x-font", - "pfb": "application/x-font", - "gsf": "application/x-font", - "pcf": "application/x-font", - "pcf.Z": "application/x-font", - "mm": "application/x-freemind", - "spl": "application/x-futuresplash", - "gnumeric": "application/x-gnumeric", - "sgf": "application/x-go-sgf", - "gcf": "application/x-graphing-calculator", - "gtar": "application/x-gtar", - "tgz": "application/x-gtar", - "taz": "application/x-gtar", - "hdf": "application/x-hdf", - "phtml": "application/x-httpd-php", - "pht": "application/x-httpd-php", - "php": "application/x-httpd-php", - "phps": "application/x-httpd-php-source", - "php3": "application/x-httpd-php3", - "php3p": "application/x-httpd-php3-preprocessed", - "php4": "application/x-httpd-php4", - "php5": "application/x-httpd-php5", - "ica": "application/x-ica", - "info": "application/x-info", - "ins": "application/x-internet-signup", - "isp": "application/x-internet-signup", - "iii": "application/x-iphone", - "iso": "application/x-iso9660-image", - "jam": "application/x-jam", - "jnlp": "application/x-java-jnlp-file", - "jmz": "application/x-jmol", - "chrt": "application/x-kchart", - "kil": "application/x-killustrator", - "skp": "application/x-koan", - "skd": "application/x-koan", - "skt": "application/x-koan", - "skm": "application/x-koan", - "kpr": "application/x-kpresenter", - "kpt": "application/x-kpresenter", - "ksp": "application/x-kspread", - "kwd": "application/x-kword", - "kwt": "application/x-kword", - "latex": "application/x-latex", - "lha": "application/x-lha", - "lyx": "application/x-lyx", - "lzh": "application/x-lzh", - "lzx": "application/x-lzx", - "frm": "application/x-maker", - "maker": "application/x-maker", - "frame": "application/x-maker", - "fm": "application/x-maker", - "fb": "application/x-maker", - "book": "application/x-maker", - "fbdoc": "application/x-maker", - "mif": "application/x-mif", - "wmd": "application/x-ms-wmd", - "wmz": "application/x-ms-wmz", - "com": "application/x-msdos-program", - "exe": "application/x-msdos-program", - "bat": "application/x-msdos-program", - "dll": "application/x-msdos-program", - "msi": "application/x-msi", - "nc": "application/x-netcdf", - "pac": "application/x-ns-proxy-autoconfig", - "dat": "application/x-ns-proxy-autoconfig", - "nwc": "application/x-nwc", - "o": "application/x-object", - "oza": "application/x-oz-application", - "p7r": "application/x-pkcs7-certreqresp", - "crl": "application/x-pkcs7-crl", - "pyc": "application/x-python-code", - "pyo": "application/x-python-code", - "qgs": "application/x-qgis", - "shp": "application/x-qgis", - "shx": "application/x-qgis", - "qtl": "application/x-quicktimeplayer", - "rpm": "application/x-redhat-package-manager", - "rb": "application/x-ruby", - "sh": "application/x-sh", - "shar": "application/x-shar", - "swf": "application/x-shockwave-flash", - "swfl": "application/x-shockwave-flash", - "scr": "application/x-silverlight", - "sit": "application/x-stuffit", - "sitx": "application/x-stuffit", - "sv4cpio": "application/x-sv4cpio", - "sv4crc": "application/x-sv4crc", - "tar": "application/x-tar", - "tcl": "application/x-tcl", - "gf": "application/x-tex-gf", - "pk": "application/x-tex-pk", - "texinfo": "application/x-texinfo", - "texi": "application/x-texinfo", - "~": "application/x-trash", - "%": "application/x-trash", - "bak": "application/x-trash", - "old": "application/x-trash", - "sik": "application/x-trash", - "t": "application/x-troff", - "tr": "application/x-troff", - "roff": "application/x-troff", - "man": "application/x-troff-man", - "me": "application/x-troff-me", - "ms": "application/x-troff-ms", - "ustar": "application/x-ustar", - "src": "application/x-wais-source", - "wz": "application/x-wingz", - "crt": "application/x-x509-ca-cert", - "xcf": "application/x-xcf", - "fig": "application/x-xfig", - "xpi": "application/x-xpinstall", - "wasm": "application/wasm", - "amr": "audio/amr", - "awb": "audio/amr-wb", - "amr": "audio/amr", - "awb": "audio/amr-wb", - "axa": "audio/annodex", - "au": "audio/basic", - "snd": "audio/basic", - "flac": "audio/flac", - "mid": "audio/midi", - "midi": "audio/midi", - "kar": "audio/midi", - "mpga": "audio/mpeg", - "mpega": "audio/mpeg", - "mp2": "audio/mpeg", - "mp3": "audio/mpeg", - "m4a": "audio/mpeg", - "m3u": "audio/mpegurl", - "oga": "audio/ogg", - "ogg": "audio/ogg", - "spx": "audio/ogg", - "sid": "audio/prs.sid", - "aif": "audio/x-aiff", - "aiff": "audio/x-aiff", - "aifc": "audio/x-aiff", - "gsm": "audio/x-gsm", - "m3u": "audio/x-mpegurl", - "wma": "audio/x-ms-wma", - "wax": "audio/x-ms-wax", - "ra": "audio/x-pn-realaudio", - "rm": "audio/x-pn-realaudio", - "ram": "audio/x-pn-realaudio", - "ra": "audio/x-realaudio", - "pls": "audio/x-scpls", - "sd2": "audio/x-sd2", - "wav": "audio/x-wav", - "alc": "chemical/x-alchemy", - "cac": "chemical/x-cache", - "cache": "chemical/x-cache", - "csf": "chemical/x-cache-csf", - "cbin": "chemical/x-cactvs-binary", - "cascii": "chemical/x-cactvs-binary", - "ctab": "chemical/x-cactvs-binary", - "cdx": "chemical/x-cdx", - "cer": "chemical/x-cerius", - "c3d": "chemical/x-chem3d", - "chm": "chemical/x-chemdraw", - "cif": "chemical/x-cif", - "cmdf": "chemical/x-cmdf", - "cml": "chemical/x-cml", - "cpa": "chemical/x-compass", - "bsd": "chemical/x-crossfire", - "csml": "chemical/x-csml", - "csm": "chemical/x-csml", - "ctx": "chemical/x-ctx", - "cxf": "chemical/x-cxf", - "cef": "chemical/x-cxf", - "smi": "#chemical/x-daylight-smiles", - "emb": "chemical/x-embl-dl-nucleotide", - "embl": "chemical/x-embl-dl-nucleotide", - "spc": "chemical/x-galactic-spc", - "inp": "chemical/x-gamess-input", - "gam": "chemical/x-gamess-input", - "gamin": "chemical/x-gamess-input", - "fch": "chemical/x-gaussian-checkpoint", - "fchk": "chemical/x-gaussian-checkpoint", - "cub": "chemical/x-gaussian-cube", - "gau": "chemical/x-gaussian-input", - "gjc": "chemical/x-gaussian-input", - "gjf": "chemical/x-gaussian-input", - "gal": "chemical/x-gaussian-log", - "gcg": "chemical/x-gcg8-sequence", - "gen": "chemical/x-genbank", - "hin": "chemical/x-hin", - "istr": "chemical/x-isostar", - "ist": "chemical/x-isostar", - "jdx": "chemical/x-jcamp-dx", - "dx": "chemical/x-jcamp-dx", - "kin": "chemical/x-kinemage", - "mcm": "chemical/x-macmolecule", - "mmd": "chemical/x-macromodel-input", - "mmod": "chemical/x-macromodel-input", - "mol": "chemical/x-mdl-molfile", - "rd": "chemical/x-mdl-rdfile", - "rxn": "chemical/x-mdl-rxnfile", - "sd": "chemical/x-mdl-sdfile", - "sdf": "chemical/x-mdl-sdfile", - "tgf": "chemical/x-mdl-tgf", - "mif": "#chemical/x-mif", - "mcif": "chemical/x-mmcif", - "mol2": "chemical/x-mol2", - "b": "chemical/x-molconn-Z", - "gpt": "chemical/x-mopac-graph", - "mop": "chemical/x-mopac-input", - "mopcrt": "chemical/x-mopac-input", - "mpc": "chemical/x-mopac-input", - "zmt": "chemical/x-mopac-input", - "moo": "chemical/x-mopac-out", - "mvb": "chemical/x-mopac-vib", - "asn": "chemical/x-ncbi-asn1", - "prt": "chemical/x-ncbi-asn1-ascii", - "ent": "chemical/x-ncbi-asn1-ascii", - "val": "chemical/x-ncbi-asn1-binary", - "aso": "chemical/x-ncbi-asn1-binary", - "asn": "chemical/x-ncbi-asn1-spec", - "pdb": "chemical/x-pdb", - "ent": "chemical/x-pdb", - "ros": "chemical/x-rosdal", - "sw": "chemical/x-swissprot", - "vms": "chemical/x-vamas-iso14976", - "vmd": "chemical/x-vmd", - "xtel": "chemical/x-xtel", - "xyz": "chemical/x-xyz", - "gif": "image/gif", - "ief": "image/ief", - "jpeg": "image/jpeg", - "jpg": "image/jpeg", - "jpe": "image/jpeg", - "pcx": "image/pcx", - "png": "image/png", - "svg": "image/svg+xml", - "svgz": "image/svg+xml", - "tiff": "image/tiff", - "tif": "image/tiff", - "djvu": "image/vnd.djvu", - "djv": "image/vnd.djvu", - "wbmp": "image/vnd.wap.wbmp", - "cr2": "image/x-canon-cr2", - "crw": "image/x-canon-crw", - "ras": "image/x-cmu-raster", - "cdr": "image/x-coreldraw", - "pat": "image/x-coreldrawpattern", - "cdt": "image/x-coreldrawtemplate", - "cpt": "image/x-corelphotopaint", - "erf": "image/x-epson-erf", - "ico": "image/x-icon", - "art": "image/x-jg", - "jng": "image/x-jng", - "bmp": "image/x-ms-bmp", - "nef": "image/x-nikon-nef", - "orf": "image/x-olympus-orf", - "psd": "image/x-photoshop", - "pnm": "image/x-portable-anymap", - "pbm": "image/x-portable-bitmap", - "pgm": "image/x-portable-graymap", - "ppm": "image/x-portable-pixmap", - "rgb": "image/x-rgb", - "xbm": "image/x-xbitmap", - "xpm": "image/x-xpixmap", - "xwd": "image/x-xwindowdump", - "eml": "message/rfc822", - "igs": "model/iges", - "iges": "model/iges", - "msh": "model/mesh", - "mesh": "model/mesh", - "silo": "model/mesh", - "wrl": "model/vrml", - "vrml": "model/vrml", - "x3dv": "model/x3d+vrml", - "x3d": "model/x3d+xml", - "x3db": "model/x3d+binary", - "manifest": "text/cache-manifest", - "ics": "text/calendar", - "icz": "text/calendar", - "css": "text/css", - "csv": "text/csv", - "323": "text/h323", - "html": "text/html", - "htm": "text/html", - "shtml": "text/html", - "uls": "text/iuls", - "mml": "text/mathml", - "asc": "text/plain", - "txt": "text/plain", - "text": "text/plain", - "pot": "text/plain", - "brf": "text/plain", - "rtx": "text/richtext", - "sct": "text/scriptlet", - "wsc": "text/scriptlet", - "tm": "text/texmacs", - "ts": "text/texmacs", - "tsv": "text/tab-separated-values", - "jad": "text/vnd.sun.j2me.app-descriptor", - "wml": "text/vnd.wap.wml", - "wmls": "text/vnd.wap.wmlscript", - "bib": "text/x-bibtex", - "boo": "text/x-boo", - "h++": "text/x-c++hdr", - "hpp": "text/x-c++hdr", - "hxx": "text/x-c++hdr", - "hh": "text/x-c++hdr", - "c++": "text/x-c++src", - "cpp": "text/x-c++src", - "cxx": "text/x-c++src", - "cc": "text/x-c++src", - "h": "text/x-chdr", - "htc": "text/x-component", - "csh": "text/x-csh", - "c": "text/x-csrc", - "d": "text/x-dsrc", - "diff": "text/x-diff", - "patch": "text/x-diff", - "hs": "text/x-haskell", - "java": "text/x-java", - "lhs": "text/x-literate-haskell", - "moc": "text/x-moc", - "p": "text/x-pascal", - "pas": "text/x-pascal", - "gcd": "text/x-pcs-gcd", - "pl": "text/x-perl", - "pm": "text/x-perl", - "py": "text/x-python", - "scala": "text/x-scala", - "etx": "text/x-setext", - "sh": "text/x-sh", - "tcl": "text/x-tcl", - "tk": "text/x-tcl", - "tex": "text/x-tex", - "ltx": "text/x-tex", - "sty": "text/x-tex", - "cls": "text/x-tex", - "vcs": "text/x-vcalendar", - "vcf": "text/x-vcard", - "3gp": "video/3gpp", - "axv": "video/annodex", - "dl": "video/dl", - "dif": "video/dv", - "dv": "video/dv", - "fli": "video/fli", - "gl": "video/gl", - "mpeg": "video/mpeg", - "mpg": "video/mpeg", - "mpe": "video/mpeg", - "mp4": "video/mp4", - "qt": "video/quicktime", - "mov": "video/quicktime", - "ogv": "video/ogg", - "mxu": "video/vnd.mpegurl", - "flv": "video/x-flv", - "lsf": "video/x-la-asf", - "lsx": "video/x-la-asf", - "mng": "video/x-mng", - "asf": "video/x-ms-asf", - "asx": "video/x-ms-asf", - "wm": "video/x-ms-wm", - "wmv": "video/x-ms-wmv", - "wmx": "video/x-ms-wmx", - "wvx": "video/x-ms-wvx", - "avi": "video/x-msvideo", - "movie": "video/x-sgi-movie", - "mpv": "video/x-matroska", - "mkv": "video/x-matroska", - "ice": "x-conference/x-cooltalk", - "sisx": "x-epoc/x-sisx-app", - "vrm": "x-world/x-vrml", - "vrml": "x-world/x-vrml", - "wrl": "x-world/x-vrml"} + "123": "application/vnd.lotus-1-2-3", + "1km": "application/vnd.1000minds.decision-model+xml", + "323": "text/h323", + "3dm": "text/vnd.in3d.3dml", + "3dmf": "x-world/x-3dmf", + "3dml": "text/vnd.in3d.3dml", + "3ds": "image/x-3ds", + "3g2": "video/3gpp2", + "3gp": "video/3gpp", + "3gpp": "audio/3gpp", + "3gpp2": "video/3gpp2", + "3mf": "application/vnd.ms-3mfdocument", + "669": "audio/x-mod", + "726": "audio/32kadpcm", + "7z": "application/x-7z-compressed", + "a": "text/plain", + "a2l": "application/a2l", + "aa3": "audio/atrac3", + "aab": "application/x-authorware-bin", + "aac": "audio/x-aac", + "aal": "audio/atrac-advanced-lossless", + "aam": "application/x-authorware-map", + "aas": "application/x-authorware-seg", + "abc": "text/vnd.abc", + "abw": "application/x-abiword", + "ac": "application/pkix-attr-cert", + "ac3": "audio/ac3", + "acc": "application/vnd.americandynamics.acc", + "ace": "application/x-ace-compressed", + "acn": "audio/asc", + "acu": "application/vnd.acucobol", + "acutc": "application/vnd.acucorp", + "acx": "application/internet-property-stream", + "adp": "audio/adpcm", + "aep": "application/vnd.audiograph", + "afl": "video/animaflex", + "afm": "application/x-font-type1", + "afp": "application/vnd.ibm.modcap", + "ahead": "application/vnd.ahead.space", + "ai": "application/postscript", + "aif": "audio/x-aiff", + "aifc": "audio/x-aiff", + "aiff": "audio/x-aiff", + "aim": "application/x-aim", + "aip": "text/x-audiosoft-intra", + "air": "application/vnd.adobe.air-application-installer-package+zip", + "ait": "application/vnd.dvb.ait", + "alc": "chemical/x-alchemy", + "ami": "application/vnd.amiga.ami", + "aml": "application/aml", + "amr": "audio/amr", + "ani": "application/x-navi-animation", + "anx": "application/x-annodex", + "aos": "application/x-nokia-9000-communicator-add-on-software", + "apinotes": "text/apinotes", + "apk": "application/vnd.android.package-archive", + "apkg": "application/vnd.anki", + "apng": "image/apng", + "appcache": "text/cache-manifest", + "appimage": "application/appimage", + "application": "application/x-ms-application", + "apr": "application/vnd.lotus-approach", + "aps": "application/mime", + "apxml": "application/auth-policy+xml", + "arc": "application/x-freearc", + "arj": "application/x-arj", + "art": "message/rfc822", + "asar": "binary/asar", + "asc": "text/plain", + "ascii": "text/vnd.ascii-art", + "asf": "application/vnd.ms-asf", + "asice": "application/vnd.etsi.asic-e+zip", + "asics": "application/vnd.etsi.asic-s+zip", + "asm": "text/x-asm", + "asn": "chemical/x-ncbi-asn1-spec", + "aso": "application/vnd.accpac.simply.aso", + "asp": "text/asp", + "asr": "video/x-ms-asf", + "asx": "video/x-ms-asf", + "at3": "audio/atrac3", + "atc": "application/vnd.acucorp", + "atf": "application/atf", + "atfx": "application/atfx", + "atom": "application/atom+xml", + "atomcat": "application/atomcat+xml", + "atomdeleted": "application/atomdeleted+xml", + "atomsrv": "application/atomserv+xml", + "atomsvc": "application/atomsvc+xml", + "atx": "application/vnd.antix.game-component", + "atxml": "application/atxml", + "au": "audio/basic", + "auc": "application/tamp-apex-update-confirm", + "avi": "video/x-msvideo", + "avs": "video/avs-video", + "aw": "application/applixware", + "awb": "audio/amr-wb", + "axa": "audio/x-annodex", + "axs": "application/olescript", + "axv": "video/x-annodex", + "azf": "application/vnd.airzip.filesecure.azf", + "azs": "application/vnd.airzip.filesecure.azs", + "azv": "image/vnd.airzip.accelerator.azv", + "azw": "application/vnd.amazon.ebook", + "azw3": "application/vnd.amazon.mobi8-ebook", + "b": "chemical/x-molconn-Z", + "bak": "application/x-trash", + "bar": "application/vnd.qualcomm.brew-app-res", + "bas": "text/plain", + "bash": "text/shell", + "bat": "application/x-msdos-program", + "bcpio": "application/x-bcpio", + "bdf": "application/x-font-bdf", + "bdm": "application/vnd.syncml.dm+wbxml", + "bdoc": "application/bdoc", + "bed": "application/vnd.realvnc.bed", + "bh2": "application/vnd.fujitsu.oasysprs", + "bib": "text/x-bibtex", + "bik": "video/vnd.radgamettools.bink", + "bin": "application/octet-stream", + "bk2": "video/vnd.radgamettools.bink", + "bkm": "application/vnd.nervana", + "blb": "application/x-blorb", + "blend": "binary/blender", + "blorb": "application/x-blorb", + "bm": "image/bmp", + "bmed": "multipart/vnd.bint.med-plus", + "bmi": "application/vnd.bmi", + "bmml": "application/vnd.balsamiq.bmml+xml", + "bmp": "image/bmp", + "bmpr": "application/vnd.balsamiq.bmpr", + "boo": "application/book", + "book": "application/book", + "box": "application/vnd.previewsystems.box", + "boz": "application/x-bzip2", + "bpd": "application/vnd.hbci", + "bpk": "application/octet-stream", + "brf": "text/plain", + "bsd": "chemical/x-crossfire", + "bsh": "application/x-bsh", + "bsp": "model/vnd.valve.source.compiled-map", + "btf": "image/prs.btif", + "btif": "image/prs.btif", + "bz": "application/x-bzip", + "bz2": "application/x-bzip2", + "c": "text/x-csrc", + "c++": "text/x-c++src", + "c11amc": "application/vnd.cluetrust.cartomobile-config", + "c11amz": "application/vnd.cluetrust.cartomobile-config-pkg", + "c3d": "chemical/x-chem3d", + "c3ex": "application/cccex", + "c4d": "application/vnd.clonk.c4group", + "c4f": "application/vnd.clonk.c4group", + "c4g": "application/vnd.clonk.c4group", + "c4p": "application/vnd.clonk.c4group", + "c4u": "application/vnd.clonk.c4group", + "cab": "application/vnd.ms-cab-compressed", + "cac": "chemical/x-cache", + "cache": "application/x-cache", + "caf": "audio/x-caf", + "cap": "application/vnd.tcpdump.pcap", + "car": "application/vnd.curl.car", + "cascii": "chemical/x-cactvs-binary", + "cat": "application/vnd.ms-pki.seccat", + "cb7": "application/x-cbr", + "cba": "application/x-cbr", + "cbin": "chemical/x-cactvs-binary", + "cbor": "application/cbor", + "cbr": "application/x-cbr", + "cbt": "application/x-cbr", + "cbz": "application/vnd.comicbook+zip", + "cc": "text/plain", + "ccad": "application/clariscad", + "ccc": "text/vnd.net2phone.commcenter.command", + "ccmp": "application/ccmp+xml", + "cco": "application/x-cocoa", + "cct": "application/x-director", + "ccxml": "application/ccxml+xml", + "cda": "application/x-cdf", + "cdbcmsg": "application/vnd.contact.cmsg", + "cdf": "application/x-netcdf", + "cdfx": "application/cdfx+xml", + "cdkey": "application/vnd.mediastation.cdkey", + "cdmia": "application/cdmi-capability", + "cdmic": "application/cdmi-container", + "cdmid": "application/cdmi-domain", + "cdmio": "application/cdmi-object", + "cdmiq": "application/cdmi-queue", + "cdr": "image/x-coreldraw", + "cdt": "image/x-coreldrawtemplate", + "cdx": "chemical/x-cdx", + "cdxml": "application/vnd.chemdraw+xml", + "cdy": "application/vnd.cinderella", + "cea": "application/cea", + "cef": "chemical/x-cxf", + "cellml": "application/cellml+xml", + "cer": "application/pkix-cert", + "cfg": "text/cfg", + "cfs": "application/x-cfs-compressed", + "cgm": "image/cgm", + "cha": "application/x-chat", + "chat": "application/x-chat", + "chm": "application/vnd.ms-htmlhelp", + "chrt": "application/vnd.kde.kchart", + "cif": "chemical/x-cif", + "cii": "application/vnd.anser-web-certificate-issue-initiation", + "cil": "application/vnd.ms-artgalry", + "cl": "application/simple-filter+xml", + "cla": "application/vnd.claymore", + "class": "application/java-vm", + "clkk": "application/vnd.crick.clicker.keyboard", + "clkp": "application/vnd.crick.clicker.palette", + "clkt": "application/vnd.crick.clicker.template", + "clkw": "application/vnd.crick.clicker.wordbank", + "clkx": "application/vnd.crick.clicker", + "clp": "application/x-msclip", + "cls": "text/x-tex", + "clue": "application/clue_info+xml", + "cmake": "text/cmake", + "cmc": "application/vnd.cosmocaller", + "cmdf": "chemical/x-cmdf", + "cml": "chemical/x-cml", + "cmp": "application/vnd.yellowriver-custom-menu", + "cmsc": "application/cms", + "cmx": "image/x-cmx", + "cnd": "text/jcr-cnd", + "cnf": "text/cnf", + "cod": "application/vnd.rim.cod", + "coffee": "application/vnd.coffeescript", + "com": "application/x-msdos-program", + "conf": "text/plain", + "copyright": "text/vnd.debian.copyright", + "cpa": "chemical/x-compass", + "cpio": "application/x-cpio", + "cpkg": "application/vnd.xmpie.cpkg", + "cpl": "application/cpl+xml", + "cpp": "text/x-c++src", + "cpt": "application/mac-compactpro", + "cr2": "image/x-canon-cr2", + "crd": "application/x-mscardfile", + "crl": "application/pkix-crl", + "crt": "application/x-x509-ca-cert", + "crtr": "application/vnd.multiad.creator", + "crw": "image/x-canon-crw", + "crx": "application/x-chrome-extension", + "cryptonote": "application/vnd.rig.cryptonote", + "cs": "text/c#", + "csf": "chemical/x-cache-csf", + "csh": "application/x-csh", + "csl": "application/vnd.citationstyles.style+xml", + "csm": "chemical/x-csml", + "csml": "chemical/x-csml", + "cson": "text/cson", + "csp": "application/vnd.commonspace", + "csrattrs": "application/csrattrs", + "css": "text/css", + "cst": "application/vnd.commonspace", + "csv": "text/csv", + "csvs": "text/csv-schema", + "ctab": "chemical/x-cactvs-binary", + "ctx": "chemical/x-ctx", + "cu": "application/cu-seeme", + "cub": "chemical/x-gaussian-cube", + "cuc": "application/tamp-community-update-confirm", + "curl": "text/vnd.curl", + "cw": "application/prs.cww", + "cww": "application/prs.cww", + "cxf": "chemical/x-cxf", + "cxt": "application/x-director", + "cxx": "text/plain", + "d": "text/x-dsrc", + "dae": "model/vnd.collada+xml", + "daf": "application/vnd.mobius.daf", + "dart": "application/vnd.dart", + "dat": "application/x-ns-proxy-autoconfig", + "dataless": "application/vnd.fdsn.seed", + "davmount": "application/davmount+xml", + "dbk": "application/docbook+xml", + "dcd": "application/dcd", + "dcf": "application/vnd.oma.drm.content", + "dcm": "application/dicom", + "dcr": "application/x-director", + "dcurl": "text/vnd.curl.dcurl", + "dd": "application/vnd.oma.dd+xml", + "dd2": "application/vnd.oma.dd2+xml", + "ddd": "application/vnd.fujixerox.ddd", + "ddf": "application/vnd.syncml.dmddf+xml", + "deb": "application/vnd.debian.binary-package", + "deepv": "application/x-deepv", + "def": "text/plain", + "deploy": "application/octet-stream", + "der": "application/x-x509-ca-cert", + "dfac": "application/vnd.dreamfactory", + "dgc": "application/x-dgc-compressed", + "dib": "image/bmp", + "dic": "text/x-c", + "dif": "video/x-dv", + "diff": "text/x-diff", + "dii": "application/dii", + "dim": "application/vnd.fastcopy-disk-image", + "dir": "application/x-director", + "dis": "application/vnd.mobius.dis", + "disposition-notification": "message/disposition-notification", + "dist": "application/vnd.apple.installer+xml", + "distz": "application/vnd.apple.installer+xml", + "dit": "application/dit", + "djv": "image/vnd.djvu", + "djvu": "image/vnd.djvu", + "dl": "video/dl", + "dll": "application/x-msdos-program", + "dls": "audio/dls", + "dm": "application/vnd.oma.drm.message", + "dmg": "application/x-apple-diskimage", + "dmp": "application/vnd.tcpdump.pcap", + "dms": "text/vnd.dmclientscript", + "dna": "application/vnd.dna", + "doc": "application/msword", + "docjson": "application/vnd.document+json", + "docm": "application/vnd.ms-word.document.macroenabled.12", + "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "dor": "model/vnd.gdl", + "dot": "text/vnd.graphviz", + "dotm": "application/vnd.ms-word.template.macroenabled.12", + "dotx": "application/vnd.openxmlformats-officedocument.wordprocessingml.template", + "dp": "application/vnd.osgi.dp", + "dpg": "application/vnd.dpgraph", + "dpgraph": "application/vnd.dpgraph", + "dpkg": "application/vnd.xmpie.dpkg", + "dr": "application/vnd.oma.drm.rights+xml", + "dra": "audio/vnd.dra", + "drc": "application/vnd.oma.drm.rights+wbxml", + "drle": "image/dicom-rle", + "drw": "application/drafting", + "dsc": "text/prs.lines.tag", + "dsm": "application/vnd.desmume.movie", + "dssc": "application/dssc+der", + "dtb": "application/x-dtbook+xml", + "dtd": "application/xml-dtd", + "dts": "audio/vnd.dts", + "dtshd": "audio/vnd.dts.hd", + "dump": "application/octet-stream", + "dv": "video/x-dv", + "dvb": "video/vnd.dvb.file", + "dvc": "application/dvcs", + "dvi": "application/x-dvi", + "dwf": "model/vnd.dwf", + "dwg": "image/vnd.dwg", + "dx": "chemical/x-jcamp-dx", + "dxf": "image/vnd.dxf", + "dxp": "application/vnd.spotfire.dxp", + "dxr": "application/x-director", + "dzr": "application/vnd.dzr", + "ear": "binary/zip", + "ecelp4800": "audio/vnd.nuera.ecelp4800", + "ecelp7470": "audio/vnd.nuera.ecelp7470", + "ecelp9600": "audio/vnd.nuera.ecelp9600", + "ecig": "application/vnd.evolv.ecig.settings", + "ecigprofile": "application/vnd.evolv.ecig.profile", + "ecigtheme": "application/vnd.evolv.ecig.theme", + "ecma": "application/ecmascript", + "edm": "application/vnd.novadigm.edm", + "edx": "application/vnd.novadigm.edx", + "efi": "application/efi", + "efif": "application/vnd.picsel", + "ei6": "application/vnd.pg.osasli", + "ejs": "text/ejs", + "el": "text/plain", + "elc": "application/x-bytecode.elisp", + "emb": "chemical/x-embl-dl-nucleotide", + "embl": "chemical/x-embl-dl-nucleotide", + "emf": "image/emf", + "eml": "message/rfc822", + "emm": "application/vnd.ibm.electronic-media", + "emma": "application/emma+xml", + "emotionml": "application/emotionml+xml", + "emz": "application/x-msmetafile", + "ent": "text/xml-external-parsed-entity", + "entity": "application/vnd.nervana", + "env": "application/x-envoy", + "enw": "audio/evrcnw", + "eol": "audio/vnd.digital-winds", + "eot": "application/vnd.ms-fontobject", + "ep": "application/vnd.bluetooth.ep.oob", + "eps": "application/postscript", + "eps2": "application/postscript", + "eps3": "application/postscript", + "epsf": "application/postscript", + "epsi": "application/postscript", + "epub": "application/epub+zip", + "erb": "text/erb", + "erf": "image/x-epson-erf", + "es": "application/ecmascript", + "es3": "application/vnd.eszigno3+xml", + "esa": "application/vnd.osgi.subsystem", + "escn": "text/godot", + "esf": "application/vnd.epson.esf", + "espass": "application/vnd.espass-espass+zip", + "et3": "application/vnd.eszigno3+xml", + "etx": "text/x-setext", + "eva": "application/x-eva", + "evb": "audio/evrcb", + "evc": "audio/evrc", + "evw": "audio/evrcwb", + "evy": "application/x-envoy", + "exe": "application/x-msdos-program", + "exi": "application/exi", + "exr": "image/aces", + "ext": "application/vnd.novadigm.ext", + "eyaml": "text/yaml", + "ez": "application/andrew-inset", + "ez2": "application/vnd.ezpix-album", + "ez3": "application/vnd.ezpix-package", + "f": "text/x-fortran", + "f4v": "video/x-f4v", + "f77": "text/x-fortran", + "f90": "text/plain", + "fb": "application/x-maker", + "fbdoc": "application/x-maker", + "fbs": "image/vnd.fastbidsheet", + "fbx": "model/filmbox", + "fcdt": "application/vnd.adobe.formscentral.fcdt", + "fch": "chemical/x-gaussian-checkpoint", + "fchk": "chemical/x-gaussian-checkpoint", + "fcs": "application/vnd.isac.fcs", + "fdf": "application/vnd.fdf", + "fdt": "application/fdt+xml", + "fe_launch": "application/vnd.denovo.fcselayout-link", + "feature": "text/gherkin", + "fg5": "application/vnd.fujitsu.oasysgp", + "fgd": "application/x-director", + "fh": "image/x-freehand", + "fh4": "image/x-freehand", + "fh5": "image/x-freehand", + "fh7": "image/x-freehand", + "fhc": "image/x-freehand", + "fif": "image/fif", + "fig": "application/x-xfig", + "finf": "application/fastinfoset", + "fish": "text/fish", + "fit": "image/fits", + "fits": "image/fits", + "fla": "application/vnd.dtg.local.flash", + "flac": "audio/x-flac", + "fli": "video/x-fli", + "flo": "application/vnd.micrografx.flo", + "flr": "x-world/x-vrml", + "flv": "video/x-flv", + "flw": "application/vnd.kde.kivio", + "flx": "text/vnd.fmi.flexstor", + "fly": "text/vnd.fly", + "fm": "application/vnd.framemaker", + "fmf": "video/x-atomic3d-feature", + "fnc": "application/vnd.frogans.fnc", + "fo": "application/vnd.software602.filler.form+xml", + "for": "text/x-fortran", + "fpx": "image/vnd.fpx", + "frame": "application/vnd.framemaker", + "frl": "application/freeloader", + "frm": "application/vnd.ufdl", + "fsc": "application/vnd.fsc.weblaunch", + "fst": "image/vnd.fst", + "ftc": "application/vnd.fluxtime.clip", + "fti": "application/vnd.anser-web-funds-transfer-initiation", + "fts": "image/fits", + "funk": "audio/make", + "fvt": "video/vnd.fvt", + "fxm": "video/x-javafx", + "fxp": "application/vnd.adobe.fxp", + "fxpl": "application/vnd.adobe.fxp", + "fzs": "application/vnd.fuzzysheet", + "g": "text/plain", + "g2w": "application/vnd.geoplan", + "g3": "image/g3fax", + "g3w": "application/vnd.geospace", + "gac": "application/vnd.groove-account", + "gal": "chemical/x-gaussian-log", + "gam": "application/x-tads", + "gamin": "chemical/x-gamess-input", + "gau": "chemical/x-gaussian-input", + "gbr": "application/rpki-ghostbusters", + "gca": "application/x-gca-compressed", + "gcd": "text/x-pcs-gcd", + "gcf": "application/x-graphing-calculator", + "gcg": "chemical/x-gcg8-sequence", + "gdl": "model/vnd.gdl", + "gdoc": "application/vnd.google-apps.document", + "gemspec": "text/ruby", + "gen": "chemical/x-genbank", + "geo": "application/vnd.dynageo", + "geojson": "application/geo+json", + "gex": "application/vnd.geometry-explorer", + "gf": "application/x-tex-gf", + "ggb": "application/vnd.geogebra.file", + "ggt": "application/vnd.geogebra.tool", + "ghf": "application/vnd.groove-help", + "gif": "image/gif", + "gim": "application/vnd.groove-identity-message", + "gjc": "chemical/x-gaussian-input", + "gjf": "chemical/x-gaussian-input", + "gl": "video/gl", + "glb": "model/gltf-binary", + "gltf": "model/gltf+json", + "gml": "application/gml+xml", + "gmx": "application/vnd.gmx", + "gnumeric": "application/x-gnumeric", + "go": "text/go", + "gotmpl": "text/gotmpl", + "gph": "application/vnd.flographit", + "gpt": "chemical/x-mopac-graph", + "gpx": "application/gpx+xml", + "gqf": "application/vnd.grafeq", + "gqs": "application/vnd.grafeq", + "gradle": "text/groovy", + "gram": "application/srgs", + "gramps": "application/x-gramps-xml", + "gre": "application/vnd.geometry-explorer", + "groovy": "text/groovy", + "grv": "application/vnd.groove-injector", + "grxml": "application/srgs+xml", + "gsd": "audio/x-gsm", + "gsf": "application/x-font-ghostscript", + "gsheet": "application/vnd.google-apps.spreadsheet", + "gslides": "application/vnd.google-apps.presentation", + "gsm": "model/vnd.gdl", + "gsp": "application/x-gsp", + "gss": "application/x-gss", + "gtar": "application/x-gtar", + "gtm": "application/vnd.groove-tool-message", + "gtw": "model/vnd.gtw", + "gv": "text/vnd.graphviz", + "gxf": "application/gxf", + "gxt": "application/vnd.geonext", + "gyb": "text/gyb", + "gyp": "text/gyp", + "gypi": "text/gyp", + "gz": "application/gzip", + "h": "text/x-chdr", + "h++": "text/x-c++hdr", + "h261": "video/h261", + "h263": "video/h263", + "h264": "video/h264", + "hal": "application/vnd.hal+xml", + "hbc": "application/vnd.hbci", + "hbci": "application/vnd.hbci", + "hbs": "text/x-handlebars-template", + "hdd": "application/x-virtualbox-hdd", + "hdf": "application/x-hdf", + "hdr": "image/vnd.radiance", + "hdt": "application/vnd.hdt", + "heic": "image/heic", + "heics": "image/heic-sequence", + "heif": "image/heif", + "heifs": "image/heif-sequence", + "help": "application/x-helpfile", + "hgl": "application/vnd.hp-hpgl", + "hh": "text/plain", + "hin": "chemical/x-hin", + "hjson": "application/hjson", + "hlb": "text/x-script", + "hlp": "application/winhlp", + "hpg": "application/vnd.hp-hpgl", + "hpgl": "application/vnd.hp-hpgl", + "hpi": "application/vnd.hp-hpid", + "hpid": "application/vnd.hp-hpid", + "hpp": "text/x-c++hdr", + "hps": "application/vnd.hp-hps", + "hpub": "application/prs.hpub+zip", + "hqx": "application/mac-binhex40", + "hs": "text/x-haskell", + "hta": "application/hta", + "htc": "text/x-component", + "htke": "application/vnd.kenameaapp", + "html": "text/html", + "htt": "text/webviewhtml", + "hvd": "application/vnd.yamaha.hv-dic", + "hvp": "application/vnd.yamaha.hv-voice", + "hvs": "application/vnd.yamaha.hv-script", + "hx": "text/haxe", + "hxml": "text/haxe", + "hxx": "text/plain", + "i2g": "application/vnd.intergeo", + "ic0": "application/vnd.commerce-battelle", + "ic1": "application/vnd.commerce-battelle", + "ic2": "application/vnd.commerce-battelle", + "ic3": "application/vnd.commerce-battelle", + "ic4": "application/vnd.commerce-battelle", + "ic5": "application/vnd.commerce-battelle", + "ic6": "application/vnd.commerce-battelle", + "ic7": "application/vnd.commerce-battelle", + "ic8": "application/vnd.commerce-battelle", + "ica": "application/vnd.commerce-battelle", + "icc": "application/vnd.iccprofile", + "icd": "application/vnd.commerce-battelle", + "ice": "x-conference/x-cooltalk", + "icf": "application/vnd.commerce-battelle", + "icm": "application/vnd.iccprofile", + "icns": "binary/icns", + "ico": "image/x-icon", + "ics": "text/calendar", + "icz": "text/calendar", + "idc": "text/plain", + "idl": "text/idl", + "ief": "image/ief", + "iefs": "image/ief", + "ifb": "text/calendar", + "ifm": "application/vnd.shana.informed.formdata", + "iges": "model/iges", + "igl": "application/vnd.igloader", + "igm": "application/vnd.insors.igm", + "ign": "application/vnd.coreos.ignition+json", + "ignition": "application/vnd.coreos.ignition+json", + "igs": "model/iges", + "igx": "application/vnd.micrografx.igx", + "iif": "application/vnd.shana.informed.interchange", + "iii": "application/x-iphone", + "ima": "application/x-ima", + "imap": "application/x-httpd-imap", + "imf": "application/vnd.imagemeter.folder+zip", + "img": "application/octet-stream", + "imgcal": "application/vnd.3lightssoftware.imagescal", + "imi": "application/vnd.imagemeter.image+zip", + "imp": "application/vnd.accpac.simply.imp", + "ims": "application/vnd.ms-ims", + "imscc": "application/vnd.ims.imsccv1p1", + "in": "text/plain", + "inc": "text/inc", + "inf": "application/inf", + "info": "application/x-info", + "ini": "text/ini", + "ink": "application/inkml+xml", + "inkml": "application/inkml+xml", + "inp": "chemical/x-gamess-input", + "ins": "application/x-internet-signup", + "install": "application/x-install-instructions", + "iota": "application/vnd.astraea-software.iota", + "ip": "application/x-ip2", + "ipfix": "application/ipfix", + "ipk": "application/vnd.shana.informed.package", + "irm": "application/vnd.ibm.rights-management", + "irp": "application/vnd.irepository.package+xml", + "ism": "model/vnd.gdl", + "iso": "application/x-iso9660-image", + "isp": "application/x-internet-signup", + "ist": "chemical/x-isostar", + "istr": "chemical/x-isostar", + "isu": "video/x-isvideo", + "it": "audio/it", + "itp": "application/vnd.shana.informed.formtemplate", + "its": "application/its+xml", + "iv": "application/x-inventor", + "ivp": "application/vnd.immervision-ivp", + "ivr": "i-world/i-vrml", + "ivu": "application/vnd.immervision-ivu", + "ivy": "application/x-livescreen", + "j2": "text/jinja", + "jad": "text/vnd.sun.j2me.app-descriptor", + "jade": "text/jade", + "jam": "application/vnd.jam", + "jar": "application/x-java-archive", + "jardiff": "application/x-java-archive-diff", + "java": "text/x-java-source", + "jcm": "application/x-java-commerce", + "jdx": "chemical/x-jcamp-dx", + "jenkinsfile": "text/groovy", + "jfif": "image/jpeg", + "jinja": "text/jinja", + "jinja2": "text/jinja", + "jisp": "application/vnd.jisp", + "jls": "image/jls", + "jlt": "application/vnd.hp-jlyt", + "jl": "text/julia", + "jmz": "application/x-jmol", + "jng": "image/x-jng", + "jnlp": "application/x-java-jnlp-file", + "joda": "application/vnd.joost.joda-archive", + "jp2": "image/jp2", + "jpe": "image/jpeg", + "jpeg": "image/jpeg", + "jpf": "image/jpx", + "jpg": "image/jpeg", + "jpg2": "image/jp2", + "jpgm": "image/jpm", + "jpgv": "video/jpeg", + "jpm": "image/jpm", + "jps": "image/x-jps", + "jpx": "image/jpx", + "jrd": "application/jrd+json", + "js": "application/javascript", + "json": "application/json", + "json-patch": "application/json-patch+json", + "json5": "application/json5", + "jsonld": "application/ld+json", + "jsonml": "application/jsonml+json", + "jsx": "text/jsx", + "jtd": "text/vnd.esmertec.theme-descriptor", + "jut": "image/jutvision", + "kar": "audio/midi", + "karbon": "application/vnd.kde.karbon", + "kcm": "application/vnd.nervana", + "key": "application/pgp-keys", + "keynote": "application/vnd.apple.keynote", + "kfo": "application/vnd.kde.kformula", + "kia": "application/vnd.kidspiration", + "kil": "application/x-killustrator", + "kin": "chemical/x-kinemage", + "kml": "application/vnd.google-earth.kml+xml", + "kmz": "application/vnd.google-earth.kmz", + "kne": "application/vnd.kinar", + "knp": "application/vnd.kinar", + "kom": "application/vnd.hbci", + "kon": "application/vnd.kde.kontour", + "koz": "audio/vnd.audikoz", + "kpr": "application/vnd.kde.kpresenter", + "kpt": "application/vnd.kde.kpresenter", + "kpxx": "application/vnd.ds-keypoint", + "ksh": "application/x-ksh", + "ksp": "application/vnd.kde.kspread", + "kt": "text/kotlin", + "ktr": "application/vnd.kahootz", + "ktx": "image/ktx", + "ktz": "application/vnd.kahootz", + "kwd": "application/vnd.kde.kword", + "kwt": "application/vnd.kde.kword", + "l16": "audio/l16", + "la": "audio/nspaudio", + "lam": "audio/x-liveaudio", + "lasjson": "application/vnd.las.las+json", + "lasxml": "application/vnd.las.las+xml", + "latex": "application/x-latex", + "lbc": "audio/ilbc", + "lbd": "application/vnd.llamagraphics.life-balance.desktop", + "lbe": "application/vnd.llamagraphics.life-balance.exchange+xml", + "le": "application/vnd.bluetooth.le.oob", + "les": "application/vnd.hhe.lesson-player", + "less": "text/less", + "lgr": "application/lgr+xml", + "lha": "application/octet-stream", + "lhs": "text/x-literate-haskell", + "lhx": "application/octet-stream", + "lin": "application/bbolin", + "link66": "application/vnd.route66.link66+xml", + "list": "text/plain", + "list3820": "application/vnd.ibm.modcap", + "listafp": "application/vnd.ibm.modcap", + "lmp": "model/vnd.gdl", + "lnk": "application/x-ms-shortcut", + "log": "text/plain", + "lostsyncxml": "application/lostsync+xml", + "lostxml": "application/lost+xml", + "lrf": "application/octet-stream", + "lrm": "application/vnd.ms-lrm", + "lsf": "video/x-la-asf", + "lsp": "text/x-script.lisp", + "lst": "text/plain", + "lsx": "video/x-la-asf", + "ltf": "application/vnd.frogans.ltf", + "ltx": "application/x-latex", + "lua": "text/x-lua", + "luac": "application/x-lua-bytecode", + "lvp": "audio/vnd.lucent.voice", + "lwp": "application/vnd.lotus-wordpro", + "lxf": "application/lxf", + "lyx": "application/x-lyx", + "lzh": "application/octet-stream", + "lzx": "application/x-lzx", + "m": "application/vnd.wolfram.mathematica.package", + "m13": "application/x-msmediaview", + "m14": "application/x-msmediaview", + "m15": "audio/x-mod", + "m1v": "video/mpeg", + "m21": "application/mp21", + "m2a": "audio/mpeg", + "m2v": "video/mpeg", + "m3a": "audio/mpeg", + "m3g": "application/m3g", + "m3u": "audio/x-mpegurl", + "m3u8": "application/vnd.apple.mpegurl", + "m4a": "audio/x-m4a", + "m4s": "video/iso.segment", + "m4u": "video/vnd.mpegurl", + "m4v": "video/x-m4v", + "ma": "application/mathematica", + "mads": "application/mads+xml", + "mag": "application/vnd.ecowin.chart", + "mail": "message/rfc822", + "maker": "application/vnd.framemaker", + "man": "application/x-troff-man", + "manifest": "text/cache-manifest", + "map": "application/x-navimap", + "mar": "text/plain", + "markdown": "text/markdown", + "mathml": "application/mathml+xml", + "mb": "application/mathematica", + "mbd": "application/mbedlet", + "mbk": "application/vnd.mobius.mbk", + "mbox": "application/mbox", + "mc$": "application/x-magic-cap-package-1.0", + "mc1": "application/vnd.medcalcdata", + "mcd": "application/vnd.mcd", + "mcf": "image/vasa", + "mcif": "chemical/x-mmcif", + "mcm": "chemical/x-macmolecule", + "mcp": "application/netmc", + "mcurl": "text/vnd.curl.mcurl", + "md": "text/markdown", + "mdb": "application/x-msaccess", + "mdc": "application/vnd.marlin.drm.mdcf", + "mdi": "image/vnd.ms-modi", + "me": "application/x-troff-me", + "med": "audio/x-mod", + "mesh": "model/mesh", + "meta4": "application/metalink4+xml", + "metalink": "application/metalink+xml", + "mets": "application/mets+xml", + "mf4": "application/mf4", + "mfm": "application/vnd.mfmp", + "mft": "application/rpki-manifest", + "mgp": "application/vnd.osgeo.mapguide.package", + "mgz": "application/vnd.proteus.magazine", + "mht": "message/rfc822", + "mhtml": "message/rfc822", + "mib": "text/mib", + "mid": "audio/midi", + "midi": "audio/midi", + "mie": "application/x-mie", + "mif": "application/x-mif", + "mime": "message/rfc822", + "miz": "text/mizar", + "mj2": "video/mj2", + "mjf": "audio/x-vnd.audioexplosion.mjuicemediafile", + "mjp2": "video/mj2", + "mjpg": "video/x-motion-jpeg", + "mjs": "application/javascript", + "mk": "text/makefile", + "mk3d": "video/x-matroska-3d", + "mka": "audio/x-matroska", + "mkd": "text/x-markdown", + "mks": "video/x-matroska", + "mkv": "video/x-matroska", + "mlp": "application/vnd.dolby.mlp", + "mm": "application/x-freemind", + "mmd": "application/vnd.chipnuts.karaoke-mmd", + "mmdb": "application/vnd.maxmind.maxmind-db", + "mme": "application/base64", + "mmf": "application/vnd.smaf", + "mml": "text/mathml", + "mmod": "chemical/x-macromodel-input", + "mmr": "image/vnd.fujixerox.edmics-mmr", + "mms": "application/vnd.wap.mms-message", + "mng": "video/x-mng", + "mny": "application/x-msmoney", + "mobi": "application/x-mobipocket-ebook", + "moc": "text/x-moc", + "mod": "audio/x-mod", + "model-inter": "application/vnd.vd-study", + "mods": "application/mods+xml", + "modulemap": "text/modulemap", + "mol": "chemical/x-mdl-molfile", + "mol2": "chemical/x-mol2", + "moml": "model/vnd.moml+xml", + "moo": "chemical/x-mopac-out", + "moov": "video/quicktime", + "mop": "chemical/x-mopac-input", + "mopcrt": "chemical/x-mopac-input", + "mov": "video/quicktime", + "movie": "video/x-sgi-movie", + "mp1": "audio/mpeg", + "mp2": "audio/mpeg", + "mp21": "application/mp21", + "mp2a": "audio/mpeg", + "mp3": "audio/mp3", + "mp4": "video/mp4", + "mp4a": "audio/mp4", + "mp4s": "application/mp4", + "mp4v": "video/mp4", + "mpa": "video/mpeg", + "mpc": "application/vnd.mophun.certificate", + "mpd": "application/dash+xml", + "mpdd": "application/dashdelta", + "mpe": "video/mpeg", + "mpeg": "video/mpeg", + "mpega": "audio/mpeg", + "mpf": "text/vnd.ms-mediapackage", + "mpg": "video/mpeg", + "mpg4": "video/mp4", + "mpga": "audio/mpeg", + "mpkg": "application/vnd.apple.installer+xml", + "mpm": "application/vnd.blueice.multipass", + "mpn": "application/vnd.mophun.application", + "mpp": "application/vnd.ms-project", + "mpt": "application/vnd.ms-project", + "mpv": "application/x-project", + "mpv2": "video/mpeg", + "mpx": "application/x-project", + "mpy": "application/vnd.ibm.minipay", + "mqy": "application/vnd.mobius.mqy", + "mrc": "application/marc", + "mrcx": "application/marcxml+xml", + "ms": "application/x-troff-ms", + "msa": "application/vnd.msa-disk-image", + "mscml": "application/mediaservercontrol+xml", + "msd": "application/vnd.fdsn.mseed", + "mseed": "application/vnd.fdsn.mseed", + "mseq": "application/vnd.mseq", + "msf": "application/vnd.epson.msf", + "msg": "application/vnd.ms-outlook", + "msh": "model/mesh", + "msi": "application/x-msi", + "msl": "application/vnd.mobius.msl", + "msm": "model/vnd.gdl", + "msty": "application/vnd.muvee.style", + "mtm": "audio/x-mod", + "mts": "model/vnd.mts", + "multitrack": "audio/vnd.presonus.multitrack", + "mus": "application/vnd.musician", + "musd": "application/mmt-usd+xml", + "musicxml": "application/vnd.recordare.musicxml+xml", + "mv": "video/x-sgi-movie", + "mvb": "application/x-msmediaview", + "mvt": "application/vnd.mapbox-vector-tile", + "mwc": "application/vnd.dpgraph", + "mwf": "application/vnd.mfer", + "mxf": "application/mxf", + "mxi": "application/vnd.vd-study", + "mxl": "application/vnd.recordare.musicxml", + "mxmf": "audio/mobile-xmf", + "mxml": "application/xv+xml", + "mxs": "application/vnd.triscape.mxs", + "mxu": "video/vnd.mpegurl", + "my": "audio/make", + "mzz": "application/x-vnd.audioexplosion.mzz", + "n-gage": "application/vnd.nokia.n-gage.symbian.install", + "n3": "text/n3", + "nap": "image/naplps", + "naplps": "image/naplps", + "nb": "application/mathematica", + "nbp": "application/vnd.wolfram.player", + "nc": "application/x-netcdf", + "ncm": "application/vnd.nokia.configuration-message", + "ncx": "application/x-dtbncx+xml", + "ndc": "application/vnd.osa.netdeploy", + "ndjson": "application/json", + "ndl": "application/vnd.lotus-notes", + "nds": "application/vnd.nintendo.nitro.rom", + "nef": "image/x-nikon-nef", + "nfo": "text/x-nfo", + "ngdat": "application/vnd.nokia.n-gage.data", + "ngdoc": "text/ngdoc", + "nif": "image/x-niff", + "niff": "image/x-niff", + "nim": "text/nim", + "nimble": "text/nimble", + "nims": "text/nim", + "nitf": "application/vnd.nitf", + "nix": "application/x-mix-transfer", + "nlu": "application/vnd.neurolanguage.nlu", + "nml": "application/vnd.enliven", + "nnd": "application/vnd.noblenet-directory", + "nns": "application/vnd.noblenet-sealer", + "nnw": "application/vnd.noblenet-web", + "notebook": "application/vnd.smart.notebook", + "npx": "image/vnd.net-fpx", + "nq": "application/n-quads", + "ns2": "application/vnd.lotus-notes", + "ns3": "application/vnd.lotus-notes", + "ns4": "application/vnd.lotus-notes", + "nsc": "application/x-conference", + "nsf": "application/vnd.lotus-notes", + "nsg": "application/vnd.lotus-notes", + "nsh": "application/vnd.lotus-notes", + "nt": "application/n-triples", + "ntf": "application/vnd.lotus-notes", + "numbers": "application/vnd.apple.numbers", + "nvd": "application/x-navidoc", + "nwc": "application/x-nwc", + "nws": "message/rfc822", + "nzb": "application/x-nzb", + "o": "application/x-object", + "o4a": "application/vnd.oma.drm.dcf", + "o4v": "application/vnd.oma.drm.dcf", + "oa2": "application/vnd.fujitsu.oasys2", + "oa3": "application/vnd.fujitsu.oasys3", + "oas": "application/vnd.fujitsu.oasys", + "obd": "application/x-msbinder", + "obg": "application/vnd.openblox.game-binary", + "obgx": "application/vnd.openblox.game+xml", + "obj": "application/x-tgif", + "oda": "application/oda", + "odb": "application/vnd.oasis.opendocument.database", + "odc": "application/vnd.oasis.opendocument.chart", + "odd": "application/tei+xml", + "odf": "application/vnd.oasis.opendocument.formula", + "odft": "application/vnd.oasis.opendocument.formula-template", + "odg": "application/vnd.oasis.opendocument.graphics", + "odi": "application/vnd.oasis.opendocument.image", + "odm": "application/vnd.oasis.opendocument.text-master", + "odp": "application/vnd.oasis.opendocument.presentation", + "ods": "application/vnd.oasis.opendocument.spreadsheet", + "odt": "application/vnd.oasis.opendocument.text", + "odx": "application/odx", + "oeb": "application/vnd.openeye.oeb", + "oga": "audio/ogg", + "ogex": "model/vnd.opengex", + "ogg": "audio/ogg", + "ogv": "video/ogg", + "ogx": "application/ogg", + "old": "application/x-trash", + "omc": "application/x-omc", + "omcd": "application/x-omcdatamaker", + "omcr": "application/x-omcregerator", + "omdoc": "application/omdoc+xml", + "omg": "audio/atrac3", + "onepkg": "application/onenote", + "onetmp": "application/onenote", + "onetoc": "application/onenote", + "onetoc2": "application/onenote", + "opf": "application/oebps-package+xml", + "opml": "text/x-opml", + "oprc": "application/vnd.palm", + "opus": "audio/ogg", + "or2": "application/vnd.lotus-organizer", + "or3": "application/vnd.lotus-organizer", + "orf": "image/x-olympus-orf", + "org": "text/x-org", + "orq": "application/ocsp-request", + "ors": "application/ocsp-response", + "osf": "application/vnd.yamaha.openscoreformat", + "osfpvg": "application/vnd.yamaha.openscoreformat.osfpvg+xml", + "osm": "application/vnd.openstreetmap.data+xml", + "otc": "application/vnd.oasis.opendocument.chart-template", + "otf": "font/otf", + "otg": "application/vnd.oasis.opendocument.graphics-template", + "oth": "application/vnd.oasis.opendocument.text-web", + "oti": "application/vnd.oasis.opendocument.image-template", + "otp": "application/vnd.oasis.opendocument.presentation-template", + "ots": "application/vnd.oasis.opendocument.spreadsheet-template", + "ott": "application/vnd.oasis.opendocument.text-template", + "ova": "application/x-virtualbox-ova", + "ovf": "application/x-virtualbox-ovf", + "owx": "application/owl+xml", + "oxlicg": "application/vnd.oxli.countgraph", + "oxps": "application/oxps", + "oxt": "application/vnd.openofficeorg.extension", + "oza": "application/x-oz-application", + "p": "text/x-pascal", + "p10": "application/pkcs10", + "p12": "application/pkcs12", + "p2p": "application/vnd.wfa.p2p", + "p7a": "application/x-pkcs7-signature", + "p7b": "application/x-pkcs7-certificates", + "p7c": "application/pkcs7-mime", + "p7m": "application/pkcs7-mime", + "p7r": "application/x-pkcs7-certreqresp", + "p7s": "application/pkcs7-signature", + "p8": "application/pkcs8", + "pac": "application/x-ns-proxy-autoconfig", + "pack": "application/x-java-pack200", + "package": "application/vnd.autopackage", + "pages": "application/vnd.apple.pages", + "par": "text/plain-bas", + "part": "application/pro_eng", + "pas": "text/pascal", + "pat": "image/x-coreldrawpattern", + "patch": "text/x-diff", + "paw": "application/vnd.pawaafile", + "pbd": "application/vnd.powerbuilder6", + "pbm": "image/x-portable-bitmap", + "pcap": "application/vnd.tcpdump.pcap", + "pcf": "application/x-font-pcf", + "pcl": "application/vnd.hp-pcl", + "pclxl": "application/vnd.hp-pclxl", + "pct": "image/x-pict", + "pcurl": "application/vnd.curl.pcurl", + "pcx": "image/x-pcx", + "pdb": "application/vnd.palm", + "pde": "text/x-processing", + "pdf": "application/pdf", + "pdx": "application/pdx", + "pem": "text/pem", + "pfa": "application/x-font-type1", + "pfb": "application/x-font-type1", + "pfm": "application/x-font-type1", + "pfr": "application/font-tdpfr", + "pfunk": "audio/make", + "pfx": "application/pkcs12", + "pgb": "image/vnd.globalgraphics.pgb", + "pgm": "image/x-portable-graymap", + "pgn": "application/x-chess-pgn", + "pgp": "application/pgp-encrypted", + "php": "application/x-httpd-php", + "php3": "application/x-httpd-php3", + "php3p": "application/x-httpd-php3-preprocessed", + "php4": "application/x-httpd-php4", + "php5": "application/x-httpd-php5", + "phps": "application/x-httpd-php-source", + "pht": "application/x-httpd-php", + "phtml": "application/x-httpd-php", + "pic": "image/pict", + "pict": "image/pict", + "pil": "application/vnd.piaccess.application-license", + "pk": "application/x-tex-pk", + "pkd": "application/vnd.hbci", + "pkg": "application/vnd.apple.installer+xml", + "pki": "application/pkixcmp", + "pkipath": "application/pkix-pkipath", + "pko": "application/ynd.ms-pkipko", + "pkpass": "application/vnd.apple.pkpass", + "pl": "application/x-perl", + "plantuml": "text/plantuml", + "plb": "application/vnd.3gpp.pic-bw-large", + "plc": "application/vnd.mobius.plc", + "plf": "application/vnd.pocketlearn", + "plj": "audio/vnd.everad.plj", + "plp": "application/vnd.panoply", + "pls": "application/pls+xml", + "plx": "application/x-pixclscript", + "ply": "model/stanford", + "pm": "text/plain", + "pm4": "application/x-pagemaker", + "pm5": "application/x-pagemaker", + "pma": "application/x-perfmon", + "pmc": "application/x-perfmon", + "pml": "application/vnd.ctc-posml", + "pmr": "application/x-perfmon", + "pmw": "application/x-perfmon", + "png": "image/png", + "pnm": "image/x-portable-anymap", + "po": "text/pofile", + "pod": "text/x-pod", + "portpkg": "application/vnd.macports.portpkg", + "pot": "application/vnd.ms-powerpoint", + "potm": "application/vnd.ms-powerpoint.template.macroenabled.12", + "potx": "application/vnd.openxmlformats-officedocument.presentationml.template", + "pov": "model/x-pov", + "pp": "text/puppet", + "ppa": "application/vnd.ms-powerpoint", + "ppam": "application/vnd.ms-powerpoint.addin.macroenabled.12", + "ppd": "application/vnd.cups-ppd", + "ppkg": "application/vnd.xmpie.ppkg", + "ppm": "image/x-portable-pixmap", + "pps": "application/vnd.ms-powerpoint", + "ppsm": "application/vnd.ms-powerpoint.slideshow.macroenabled.12", + "ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow", + "ppt": "application/vnd.ms-powerpoint", + "pptm": "application/vnd.ms-powerpoint.presentation.macroenabled.12", + "pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation", + "ppz": "application/mspowerpoint", + "pqa": "application/vnd.palm", + "prc": "application/vnd.palm", + "pre": "application/vnd.lotus-freelance", + "preminet": "application/vnd.preminet", + "prf": "application/pics-rules", + "proto": "text/proto", + "provn": "text/provenance-notation", + "provx": "application/provenance+xml", + "prt": "application/pro_eng", + "prz": "application/vnd.lotus-freelance", + "ps": "application/postscript", + "psb": "application/vnd.3gpp.pic-bw-small", + "psd": "image/vnd.adobe.photoshop", + "pseg3820": "application/vnd.ibm.modcap", + "psf": "application/x-font-linux-psf", + "psid": "audio/prs.sid", + "pskcxml": "application/pskc+xml", + "pti": "image/prs.pti", + "ptid": "application/vnd.pvi.ptid1", + "pub": "application/x-mspublisher", + "purs": "text/purescript", + "pvb": "application/vnd.3gpp.pic-bw-var", + "pvu": "paleovu/x-pv", + "pwn": "application/vnd.3m.post-it-notes", + "pwz": "application/vnd.ms-powerpoint", + "pxd": "text/cython", + "pxi": "text/cython", + "py": "text/x-script.phyton", + "pya": "audio/vnd.ms-playready.media.pya", + "pyc": "application/x-python-code", + "pyi": "text/pyi", + "pyo": "application/x-python-code", + "pyv": "video/vnd.ms-playready.media.pyv", + "pyx": "text/cython", + "qam": "application/vnd.epson.quickanime", + "qbo": "application/vnd.intu.qbo", + "qca": "application/vnd.ericsson.quickcall", + "qcall": "application/vnd.ericsson.quickcall", + "qcp": "audio/qcelp", + "qd3": "x-world/x-3dmf", + "qd3d": "x-world/x-3dmf", + "qfx": "application/vnd.intu.qfx", + "qgs": "application/x-qgis", + "qif": "image/x-quicktime", + "qps": "application/vnd.publishare-delta-tree", + "qt": "video/quicktime", + "qtc": "video/x-qtc", + "qti": "image/x-quicktime", + "qtif": "image/x-quicktime", + "qtl": "application/x-quicktimeplayer", + "quiz": "application/vnd.quobject-quoxdocument", + "quox": "application/vnd.quobject-quoxdocument", + "qvd": "application/vnd.theqvd", + "qwd": "application/vnd.quark.quarkxpress", + "qwt": "application/vnd.quark.quarkxpress", + "qxb": "application/vnd.quark.quarkxpress", + "qxd": "application/vnd.quark.quarkxpress", + "qxl": "application/vnd.quark.quarkxpress", + "qxt": "application/vnd.quark.quarkxpress", + "r": "text/r", + "ra": "audio/x-realaudio", + "ram": "audio/x-pn-realaudio", + "raml": "application/raml+yaml", + "rapd": "application/route-apd+xml", + "rar": "application/x-rar-compressed", + "ras": "image/x-cmu-raster", + "rast": "image/cmu-raster", + "rb": "application/x-ruby", + "rcprofile": "application/vnd.ipunplugged.rcprofile", + "rct": "application/prs.nprend", + "rd": "chemical/x-mdl-rdfile", + "rda": "text/r", + "rdata": "text/r", + "rds": "text/r", + "rdf": "application/rdf+xml", + "rdf-crypt": "application/prs.rdf-xml-crypt", + "rdz": "application/vnd.data-vision.rdz", + "relo": "application/p2p-overlay+xml", + "rep": "application/vnd.businessobjects", + "request": "application/vnd.nervana", + "res": "application/x-dtbresource+xml", + "rexx": "text/x-script.rexx", + "rf": "image/vnd.rn-realflash", + "rfcxml": "application/rfc+xml", + "rgb": "image/x-rgb", + "rgbe": "image/vnd.radiance", + "rhtml": "application/x-httpd-eruby", + "rif": "application/reginfo+xml", + "rip": "audio/vnd.rip", + "ris": "application/x-research-info-systems", + "rl": "application/resource-lists+xml", + "rlc": "image/vnd.fujixerox.edmics-rlc", + "rld": "application/resource-lists-diff+xml", + "rlib": "text/rust", + "rm": "application/vnd.rn-realmedia", + "rmi": "audio/mid", + "rmm": "audio/x-pn-realaudio", + "rmp": "audio/x-pn-realaudio-plugin", + "rms": "application/vnd.jcp.javame.midlet-rms", + "rmvb": "application/vnd.rn-realmedia-vbr", + "rnc": "application/relax-ng-compact-syntax", + "rnd": "application/prs.nprend", + "rng": "text/xml", + "rnx": "application/vnd.rn-realplayer", + "roa": "application/rpki-roa", + "roff": "text/troff", + "ros": "chemical/x-rosdal", + "rp": "image/vnd.rn-realpix", + "rp9": "application/vnd.cloanto.rp9", + "rpm": "application/x-redhat-package-manager", + "rpss": "application/vnd.nokia.radio-presets", + "rpst": "application/vnd.nokia.radio-preset", + "rq": "application/sparql-query", + "rs": "application/rls-services+xml", + "rsd": "application/rsd+xml", + "rsheet": "application/urc-ressheet+xml", + "rsm": "model/vnd.gdl", + "rss": "application/rss+xml", + "rst": "text/prs.fallenstein.rst", + "rt": "text/richtext", + "rtf": "text/rtf", + "rtx": "text/richtext", + "run": "application/x-makeself", + "rusd": "application/route-usd+xml", + "rv": "video/vnd.rn-realvideo", + "rxn": "chemical/x-mdl-rxnfile", + "s": "text/x-asm", + "s11": "video/vnd.sealed.mpeg1", + "s14": "video/vnd.sealed.mpeg4", + "s1a": "application/vnd.sealedmedia.softseal.pdf", + "s1e": "application/vnd.sealed.xls", + "s1g": "image/vnd.sealedmedia.softseal.gif", + "s1h": "application/vnd.sealedmedia.softseal.html", + "s1j": "image/vnd.sealedmedia.softseal.jpg", + "s1m": "audio/vnd.sealedmedia.softseal.mpeg", + "s1n": "image/vnd.sealed.png", + "s1p": "application/vnd.sealed.ppt", + "s1q": "video/vnd.sealedmedia.softseal.mov", + "s1w": "application/vnd.sealed.doc", + "s3df": "application/vnd.sealed.3df", + "s3m": "audio/s3m", + "sac": "application/tamp-sequence-adjust-confirm", + "saf": "application/vnd.yamaha.smaf-audio", + "sam": "application/vnd.lotus-wordpro", + "sandboxed": "text/html-sandboxed", + "sass": "text/x-sass", + "saveme": "application/octet-stream", + "sbk": "application/x-tbook", + "sbml": "application/sbml+xml", + "sc": "application/vnd.ibm.secure-container", + "scala": "text/x-scala", + "scd": "application/x-msschedule", + "sce": "application/vnd.etsi.asic-e+zip", + "scim": "application/scim+json", + "scld": "application/vnd.doremir.scorecloud-binary-document", + "scm": "application/vnd.lotus-screencam", + "scq": "application/scvp-cv-request", + "scr": "application/x-silverlight", + "scs": "application/scvp-cv-response", + "scsf": "application/vnd.sealed.csf", + "scss": "text/x-scss", + "sct": "text/scriptlet", + "scurl": "text/vnd.curl.scurl", + "sd": "chemical/x-mdl-sdfile", + "sd2": "audio/x-sd2", + "sda": "application/vnd.stardivision.draw", + "sdc": "application/vnd.stardivision.calc", + "sdd": "application/vnd.stardivision.impress", + "sdf": "application/vnd.kinar", + "sdkd": "application/vnd.solent.sdkm+xml", + "sdkm": "application/vnd.solent.sdkm+xml", + "sdml": "text/plain", + "sdo": "application/vnd.sealed.doc", + "sdoc": "application/vnd.sealed.doc", + "sdp": "application/sdp", + "sdr": "application/sounder", + "sdw": "application/vnd.stardivision.writer", + "sea": "application/x-sea", + "see": "application/vnd.seemail", + "seed": "application/vnd.fdsn.seed", + "sem": "application/vnd.sealed.eml", + "sema": "application/vnd.sema", + "semd": "application/vnd.semd", + "semf": "application/vnd.semf", + "seml": "application/vnd.sealed.eml", + "ser": "application/java-serialized-object", + "set": "application/set", + "setpay": "application/set-payment-initiation", + "setreg": "application/set-registration-initiation", + "sfc": "application/vnd.nintendo.snes.rom", + "sfd": "application/vnd.font-fontforge-sfd", + "sfd-hdstx": "application/vnd.hydrostatix.sof-data", + "sfs": "application/vnd.spotfire.sfs", + "sfv": "text/x-sfv", + "sgf": "application/x-go-sgf", + "sgi": "image/sgi", + "sgif": "image/vnd.sealedmedia.softseal.gif", + "sgl": "application/vnd.stardivision.writer-global", + "sgm": "text/sgml", + "sgml": "text/sgml", + "sh": "application/x-sh", + "shar": "application/x-shar", + "shex": "text/shex", + "shf": "application/shf+xml", + "shp": "application/x-qgis", + "shx": "application/x-qgis", + "si": "text/vnd.wap.si", + "sic": "application/vnd.wap.sic", + "sid": "image/x-mrsid-image", + "sieve": "application/sieve", + "sig": "application/pgp-signature", + "sik": "application/x-trash", + "sil": "audio/silk", + "silo": "model/mesh", + "sis": "application/vnd.symbian.install", + "sisx": "x-epoc/x-sisx-app", + "sit": "application/x-stuffit", + "sitx": "application/x-stuffitx", + "siv": "application/sieve", + "sjp": "image/vnd.sealedmedia.softseal.jpg", + "sjpg": "image/vnd.sealedmedia.softseal.jpg", + "skd": "application/vnd.koan", + "skm": "application/vnd.koan", + "skp": "application/vnd.koan", + "skt": "application/vnd.koan", + "sl": "text/vnd.wap.sl", + "sla": "application/vnd.scribus", + "slaz": "application/vnd.scribus", + "slc": "application/vnd.wap.slc", + "sldm": "application/vnd.ms-powerpoint.slide.macroenabled.12", + "sldx": "application/vnd.openxmlformats-officedocument.presentationml.slide", + "sls": "application/route-s-tsid+xml", + "slt": "application/vnd.epson.salt", + "sm": "application/vnd.stepmania.stepchart", + "smc": "application/vnd.nintendo.snes.rom", + "smf": "application/vnd.stardivision.math", + "smh": "application/vnd.sealed.mht", + "smht": "application/vnd.sealed.mht", + "smi": "application/smil+xml", + "smil": "application/smil+xml", + "smk": "video/vnd.radgamettools.smacker", + "sml": "application/smil+xml", + "smo": "video/vnd.sealedmedia.softseal.mov", + "smov": "video/vnd.sealedmedia.softseal.mov", + "smp": "audio/vnd.sealedmedia.softseal.mpeg", + "smp3": "audio/vnd.sealedmedia.softseal.mpeg", + "smpg": "video/vnd.sealed.mpeg1", + "sms": "application/vnd.3gpp2.sms", + "smv": "video/x-smv", + "smzip": "application/vnd.stepmania.package", + "snd": "audio/basic", + "snf": "application/x-font-snf", + "so": "application/octet-stream", + "soa": "text/dns", + "soc": "application/sgml-open-catalog", + "sol": "application/solids", + "spc": "text/x-speech", + "spd": "application/vnd.sealedmedia.softseal.pdf", + "spdf": "application/vnd.sealedmedia.softseal.pdf", + "spec": "text/spec", + "spf": "application/vnd.yamaha.smaf-phrase", + "spl": "application/x-futuresplash", + "spn": "image/vnd.sealed.png", + "spng": "image/vnd.sealed.png", + "spo": "text/vnd.in3d.spot", + "spot": "text/vnd.in3d.spot", + "spp": "application/scvp-vp-response", + "sppt": "application/vnd.sealed.ppt", + "spq": "application/scvp-vp-request", + "spr": "application/x-sprite", + "sprite": "application/x-sprite", + "spx": "audio/ogg", + "sql": "application/x-sql", + "sr": "application/vnd.sigrok.session", + "src": "application/x-wais-source", + "srt": "application/x-subrip", + "sru": "application/sru+xml", + "srx": "application/sparql-results+xml", + "ssdl": "application/ssdl+xml", + "sse": "application/vnd.kodak-descriptor", + "ssf": "application/vnd.epson.ssf", + "ssi": "text/x-server-parsed-html", + "ssm": "application/streamingmedia", + "ssml": "application/ssml+xml", + "sst": "application/vnd.ms-pki.certstore", + "ssw": "video/vnd.sealed.swf", + "sswf": "video/vnd.sealed.swf", + "st": "application/vnd.sailingtracker.track", + "stc": "application/vnd.sun.xml.calc.template", + "std": "application/vnd.sun.xml.draw.template", + "step": "application/step", + "stf": "application/vnd.wt.stf", + "sti": "application/vnd.sun.xml.impress.template", + "stif": "application/vnd.sealed.tiff", + "stk": "application/hyperstudio", + "stl": "application/vnd.ms-pki.stl", + "stm": "audio/x-stm", + "stml": "application/vnd.sealedmedia.softseal.html", + "stp": "application/step", + "str": "application/vnd.pg.format", + "study-inter": "application/vnd.vd-study", + "stw": "application/vnd.sun.xml.writer.template", + "sty": "text/x-tex", + "styl": "text/stylus", + "sub": "text/vnd.dvb.subtitle", + "sus": "application/vnd.sus-calendar", + "susp": "application/vnd.sus-calendar", + "sv4cpio": "application/x-sv4cpio", + "sv4crc": "application/x-sv4crc", + "svc": "application/vnd.dvb.service", + "svd": "application/vnd.svd", + "svf": "image/x-dwg", + "svg": "image/svg+xml", + "svgz": "image/svg+xml", + "sw": "chemical/x-swissprot", + "swa": "application/x-director", + "swf": "application/x-shockwave-flash", + "swfl": "application/x-shockwave-flash", + "swi": "application/vnd.aristanetworks.swi", + "swift": "text/swift", + "swiftdeps": "text/swiftdeps", + "sxc": "application/vnd.sun.xml.calc", + "sxd": "application/vnd.sun.xml.draw", + "sxg": "application/vnd.sun.xml.writer.global", + "sxi": "application/vnd.sun.xml.impress", + "sxl": "application/vnd.sealed.xls", + "sxls": "application/vnd.sealed.xls", + "sxm": "application/vnd.sun.xml.math", + "sxw": "application/vnd.sun.xml.writer", + "t": "text/troff", + "t3": "application/x-t3vm-image", + "t38": "image/t38", + "tac": "text/twisted", + "tag": "text/prs.lines.tag", + "taglet": "application/vnd.mynfc", + "talk": "text/x-speech", + "tam": "application/vnd.onepager", + "tamp": "application/vnd.onepagertamp", + "tamx": "application/vnd.onepagertamx", + "tao": "application/vnd.tao.intent-module-archive", + "tap": "image/vnd.tencent.tap", + "tar": "application/x-tar", + "tat": "application/vnd.onepagertat", + "tatp": "application/vnd.onepagertatp", + "tatx": "application/vnd.onepagertatx", + "tau": "application/tamp-apex-update", + "taz": "application/x-gtar", + "tbk": "application/toolbook", + "tcap": "application/vnd.3gpp2.tcap", + "tcl": "application/x-tcl", + "tcsh": "text/x-script.tcsh", + "tcu": "application/tamp-community-update", + "td": "application/urc-targetdesc+xml", + "teacher": "application/vnd.smart.teacher", + "tei": "application/tei+xml", + "teicorpus": "application/tei+xml", + "ter": "application/tamp-error", + "tex": "application/x-tex", + "texi": "application/x-texinfo", + "texinfo": "application/x-texinfo", + "text": "text/plain", + "tf": "text/terraform", + "tfi": "application/thraud+xml", + "tfm": "application/x-tex-tfm", + "tfx": "image/tiff-fx", + "tga": "image/x-tga", + "tgf": "chemical/x-mdl-tgf", + "tgz": "application/gzip", + "thmx": "application/vnd.ms-officetheme", + "thrift": "text/thrift", + "tif": "image/tiff", + "tiff": "image/tiff", + "tk": "text/x-tcl", + "tlclient": "application/vnd.cendio.thinlinc.clientconf", + "tm": "text/texmacs", + "tmo": "application/vnd.tmobile-livetv", + "tnef": "application/vnd.ms-tnef", + "tnf": "application/vnd.ms-tnef", + "toml": "text/toml", + "torrent": "application/x-bittorrent", + "tpl": "application/vnd.groove-tool-template", + "tpt": "application/vnd.trid.tpt", + "tr": "text/troff", + "tra": "application/vnd.trueapp", + "tree": "application/vnd.rainstor.data", + "trig": "application/trig", + "trm": "application/x-msterminal", + "ts": "video/mp2t", + "tsa": "application/tamp-sequence-adjust", + "tscn": "text/godot", + "tsd": "application/timestamped-data", + "tsi": "audio/tsp-audio", + "tsp": "audio/tsplayer", + "tsq": "application/timestamp-query", + "tsr": "application/timestamp-reply", + "tst": "application/vnd.etsi.timestamp-token", + "tsv": "text/tab-separated-values", + "tsx": "text/tsx", + "ttc": "font/collection", + "ttf": "font/ttf", + "ttl": "text/turtle", + "ttml": "application/ttml+xml", + "tuc": "application/tamp-update-confirm", + "tur": "application/tamp-update", + "turbot": "image/florian", + "twd": "application/vnd.simtech-mindmapper", + "twds": "application/vnd.simtech-mindmapper", + "txd": "application/vnd.genomatix.tuxedo", + "txf": "application/vnd.mobius.txf", + "txt": "text/plain", + "u32": "application/x-authorware-bin", + "u8dsn": "message/global-delivery-status", + "u8hdr": "message/global-headers", + "u8mdn": "message/global-disposition-notification", + "u8msg": "message/global", + "udeb": "application/vnd.debian.binary-package", + "ufd": "application/vnd.ufdl", + "ufdl": "application/vnd.ufdl", + "uil": "text/x-uil", + "uis": "application/urc-uisocketdesc+xml", + "uls": "text/iuls", + "ult": "audio/x-mod", + "ulx": "application/x-glulx", + "umj": "application/vnd.umajin", + "uni": "audio/x-mod", + "unis": "text/uri-list", + "unityweb": "application/vnd.unity", + "unv": "application/i-deas", + "uo": "application/vnd.uoml+xml", + "uoml": "application/vnd.uoml+xml", + "upa": "application/vnd.hbci", + "uri": "text/uri-list", + "uric": "text/vnd.si.uricatalogue", + "urim": "application/vnd.uri-map", + "urimap": "application/vnd.uri-map", + "uris": "text/uri-list", + "urls": "text/uri-list", + "ustar": "application/x-ustar", + "utz": "application/vnd.uiq.theme", + "uu": "text/x-uuencode", + "uue": "text/x-uuencode", + "uva": "audio/vnd.dece.audio", + "uvd": "application/vnd.dece.data", + "uvf": "application/vnd.dece.data", + "uvg": "image/vnd.dece.graphic", + "uvh": "video/vnd.dece.hd", + "uvi": "image/vnd.dece.graphic", + "uvm": "video/vnd.dece.mobile", + "uvp": "video/vnd.dece.pd", + "uvs": "video/vnd.dece.sd", + "uvt": "application/vnd.dece.ttml+xml", + "uvu": "video/vnd.dece.mp4", + "uvv": "video/vnd.dece.video", + "uvva": "audio/vnd.dece.audio", + "uvvd": "application/vnd.dece.data", + "uvvf": "application/vnd.dece.data", + "uvvg": "image/vnd.dece.graphic", + "uvvh": "video/vnd.dece.hd", + "uvvi": "image/vnd.dece.graphic", + "uvvm": "video/vnd.dece.mobile", + "uvvp": "video/vnd.dece.pd", + "uvvs": "video/vnd.dece.sd", + "uvvt": "application/vnd.dece.ttml+xml", + "uvvu": "video/vnd.dece.mp4", + "uvvv": "video/vnd.dece.video", + "uvvx": "application/vnd.dece.unspecified", + "uvvz": "application/vnd.dece.zip", + "uvx": "application/vnd.dece.unspecified", + "uvz": "application/vnd.dece.zip", + "val": "chemical/x-ncbi-asn1-binary", + "vbk": "audio/vnd.nortel.vbk", + "vbox": "application/x-virtualbox-vbox", + "vbox-extpack": "application/x-virtualbox-vbox-extpack", + "vcard": "text/vcard", + "vcd": "application/x-cdlink", + "vcf": "text/x-vcard", + "vcg": "application/vnd.groove-vcard", + "vcs": "text/x-vcalendar", + "vcx": "application/vnd.vcx", + "vda": "application/vda", + "vdi": "application/x-virtualbox-vdi", + "vdo": "video/vdo", + "vdx": "text/vdx", + "vew": "application/vnd.lotus-approach", + "vfr": "application/vnd.tml", + "vhd": "application/x-virtualbox-vhd", + "viaframe": "application/vnd.tml", + "vim": "text/vim", + "vis": "application/vnd.visionary", + "viv": "video/vnd.vivo", + "vivo": "video/vivo", + "vmd": "application/vocaltec-media-desc", + "vmdk": "application/x-virtualbox-vmdk", + "vmf": "application/vocaltec-media-file", + "vms": "chemical/x-vamas-iso14976", + "vmt": "application/vnd.valve.source.material", + "vob": "video/x-ms-vob", + "voc": "audio/voc", + "vor": "application/vnd.stardivision.writer", + "vos": "video/vosaic", + "vox": "audio/voxware", + "vpm": "multipart/voice-message", + "vqe": "audio/x-twinvq-plugin", + "vqf": "audio/x-twinvq", + "vql": "audio/x-twinvq-plugin", + "vrm": "x-world/x-vrml", + "vrml": "model/vrml", + "vrt": "x-world/x-vrt", + "vsc": "application/vnd.vidsoft.vidconference", + "vsd": "application/vnd.visio", + "vsf": "application/vnd.vsf", + "vss": "application/vnd.visio", + "vst": "application/vnd.visio", + "vsw": "application/vnd.visio", + "vtf": "image/vnd.valve.source.texture", + "vtt": "text/vtt", + "vtu": "model/vnd.vtu", + "vue": "text/vue", + "vwx": "application/vnd.vectorworks", + "vxml": "application/voicexml+xml", + "w3d": "application/x-director", + "w60": "application/wordperfect6.0", + "w61": "application/wordperfect6.1", + "w6w": "application/msword", + "wad": "application/x-doom", + "wadl": "application/vnd.sun.wadl+xml", + "war": "binary/zip", + "wasm": "application/wasm", + "wav": "audio/wave", + "wax": "audio/x-ms-wax", + "wb1": "application/x-qpro", + "wbmp": "image/vnd.wap.wbmp", + "wbs": "application/vnd.criticaltools.wbs+xml", + "wbxml": "application/vnd.wap.wbxml", + "wcm": "application/vnd.ms-works", + "wdb": "application/vnd.ms-works", + "wdp": "image/vnd.ms-photo", + "web": "application/vnd.xara", + "weba": "audio/webm", + "webapp": "application/x-web-app-manifest+json", + "webm": "video/webm", + "webmanifest": "application/manifest+json", + "webp": "image/webp", + "wg": "application/vnd.pmi.widget", + "wgt": "application/widget", + "whl": "binary/wheel", + "wif": "application/watcherinfo+xml", + "win": "model/vnd.gdl", + "wiz": "application/msword", + "wk": "application/x-123", + "wk1": "application/vnd.lotus-1-2-3", + "wk3": "application/vnd.lotus-1-2-3", + "wk4": "application/vnd.lotus-1-2-3", + "wks": "application/vnd.ms-works", + "wkt": "text/wkt", + "wlnk": "application/link-format", + "wm": "video/x-ms-wm", + "wma": "audio/x-ms-wma", + "wmc": "application/vnd.wmc", + "wmd": "application/x-ms-wmd", + "wmf": "image/wmf", + "wml": "text/vnd.wap.wml", + "wmlc": "application/vnd.wap.wmlc", + "wmls": "text/vnd.wap.wmlscript", + "wmlsc": "application/vnd.wap.wmlscriptc", + "wmv": "video/x-ms-wmv", + "wmx": "video/x-ms-wmx", + "wmz": "application/x-ms-wmz", + "woff": "font/woff", + "woff2": "font/woff2", + "word": "application/msword", + "wp": "application/wordperfect", + "wp5": "application/wordperfect", + "wp6": "application/wordperfect", + "wpd": "application/vnd.wordperfect", + "wpl": "application/vnd.ms-wpl", + "wps": "application/vnd.ms-works", + "wq1": "application/x-lotus", + "wqd": "application/vnd.wqd", + "wri": "application/x-mswrite", + "wrl": "model/vrml", + "wrz": "model/vrml", + "wsc": "message/vnd.wfa.wsc", + "wsdl": "application/wsdl+xml", + "wsgi": "text/wsgi", + "wspolicy": "application/wspolicy+xml", + "wsrc": "application/x-wais-source", + "wtb": "application/vnd.webturbo", + "wtk": "application/x-wintalk", + "wv": "application/vnd.wv.csp+wbxml", + "wvx": "video/x-ms-wvx", + "wz": "application/x-wingz", + "x-png": "image/png", + "x32": "application/x-authorware-bin", + "x3d": "application/vnd.hzn-3d-crossword", + "x3db": "model/x3d+xml", + "x3dbz": "model/x3d+binary", + "x3dv": "model/x3d-vrml", + "x3dvz": "model/x3d-vrml", + "x3dz": "model/x3d+xml", + "x_b": "model/vnd.parasolid.transmit.binary", + "x_t": "model/vnd.parasolid.transmit.text", + "xaf": "x-world/x-vrml", + "xaml": "application/xaml+xml", + "xap": "application/x-silverlight-app", + "xar": "application/vnd.xara", + "xav": "application/xcap-att+xml", + "xbap": "application/x-ms-xbap", + "xbd": "application/vnd.fujixerox.docuworks.binder", + "xbm": "image/x-xbitmap", + "xca": "application/xcap-caps+xml", + "xcf": "application/x-xcf", + "xcs": "application/calendar+xml", + "xct": "application/vnd.fujixerox.docuworks.container", + "xdd": "application/bacnet-xdd+zip", + "xdf": "application/xcap-diff+xml", + "xdm": "application/vnd.syncml.dm+xml", + "xdp": "application/vnd.adobe.xdp+xml", + "xdr": "video/x-amt-demorun", + "xdssc": "application/dssc+xml", + "xdw": "application/vnd.fujixerox.docuworks", + "xel": "application/xcap-el+xml", + "xenc": "application/xenc+xml", + "xer": "application/patch-ops-error+xml", + "xfd": "application/vnd.xfdl", + "xfdf": "application/vnd.adobe.xfdf", + "xfdl": "application/vnd.xfdl", + "xgz": "xgl/drawing", + "xht": "application/xhtml+xml", + "xhtm": "application/xhtml+xml", + "xhtml": "application/xhtml+xml", + "xhvml": "application/xv+xml", + "xif": "image/vnd.xiff", + "xl": "application/excel", + "xla": "application/vnd.ms-excel", + "xlam": "application/vnd.ms-excel.addin.macroenabled.12", + "xlb": "application/vndms-excel", + "xlc": "application/vnd.ms-excel", + "xlf": "application/x-xliff+xml", + "xlim": "application/vnd.xmpie.xlim", + "xlm": "application/vnd.ms-excel", + "xls": "application/vnd.ms-excel", + "xlsb": "application/vnd.ms-excel.sheet.binary.macroenabled.12", + "xlsm": "application/vnd.ms-excel.sheet.macroenabled.12", + "xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "xlt": "application/vnd.ms-excel", + "xltm": "application/vnd.ms-excel.template.macroenabled.12", + "xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template", + "xlw": "application/vnd.ms-excel", + "xm": "audio/xm", + "xml": "text/xml", + "xmls": "application/dskpp+xml", + "xmt_bin": "model/vnd.parasolid.transmit.binary", + "xmt_txt": "model/vnd.parasolid.transmit.text", + "xmz": "xgl/movie", + "xns": "application/xcap-ns+xml", + "xo": "application/vnd.olpc-sugar", + "xof": "x-world/x-vrml", + "xop": "application/xop+xml", + "xpdl": "application/xml", + "xpi": "application/x-xpinstall", + "xpix": "application/x-vnd.ls-xpix", + "xpl": "application/xproc+xml", + "xpm": "image/x-xpixmap", + "xpr": "application/vnd.is-xpr", + "xps": "application/vnd.ms-xpsdocument", + "xpw": "application/vnd.intercon.formnet", + "xpx": "application/vnd.intercon.formnet", + "xq": "text/xquery", + "xql": "text/xquery", + "xqm": "text/xquery", + "xqu": "text/xquery", + "xquery": "text/xquery", + "xqy": "text/xquery", + "xsd": "text/xml", + "xsf": "application/prs.xsf+xml", + "xsl": "application/xslt+xml", + "xslt": "application/xslt+xml", + "xsm": "application/vnd.syncml+xml", + "xspf": "application/xspf+xml", + "xsr": "video/x-amt-showrun", + "xtel": "chemical/x-xtel", + "xul": "application/vnd.mozilla.xul+xml", + "xvm": "application/xv+xml", + "xvml": "application/xv+xml", + "xwd": "image/x-xwindowdump", + "xyz": "chemical/x-xyz", + "xyze": "image/vnd.radiance", + "xz": "application/x-xz", + "yaml": "text/yaml", + "yang": "application/yang", + "yin": "application/yin+xml", + "yme": "application/vnd.yaoweme", + "yml": "text/yaml", + "ymp": "text/x-suse-ymp", + "z1": "application/x-zmachine", + "z2": "application/x-zmachine", + "z3": "application/x-zmachine", + "z4": "application/x-zmachine", + "z5": "application/x-zmachine", + "z6": "application/x-zmachine", + "z7": "application/x-zmachine", + "z8": "application/x-zmachine", + "zaz": "application/vnd.zzazz.deck+xml", + "zfc": "application/vnd.filmit.zfc", + "zfo": "application/vnd.software602.filler.form-xml-zip", + "zig": "text/zig", + "zip": "application/zip", + "zir": "application/vnd.zul", + "zirz": "application/vnd.zul", + "zmm": "application/vnd.handheld-entertainment+xml", + "zmt": "chemical/x-mopac-input", + "zone": "text/dns", + "zoo": "application/octet-stream", + "zsh": "text/x-script.zsh", + "~": "application/x-trash" +} from strutils import startsWith From 9f986780081bedd43ff94387b6dda2a59e799d04 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 11 Feb 2019 15:28:14 +0100 Subject: [PATCH 25/50] attempt to make nightlies work again --- koch.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koch.nim b/koch.nim index 92fc3a7663..253352c220 100644 --- a/koch.nim +++ b/koch.nim @@ -542,7 +542,7 @@ proc testUnixInstall(cmdLineRest: string) = execCleanPath("./koch --latest tools") # check the tests work: putEnv("NIM_EXE_NOT_IN_PATH", "NOT_IN_PATH") - execCleanPath("./koch tests cat megatest", destDir / "bin") + execCleanPath("./koch tests --nim:./bin/nim cat megatest", destDir / "bin") else: echo "Version check: failure" finally: From 242b6eb16c11bd4cad9dd3470396c2a760d50d78 Mon Sep 17 00:00:00 2001 From: narimiran Date: Mon, 11 Feb 2019 12:36:51 +0100 Subject: [PATCH 26/50] better docs: times --- lib/pure/times.nim | 120 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 93 insertions(+), 27 deletions(-) diff --git a/lib/pure/times.nim b/lib/pure/times.nim index 260850a0ef..2b1c4eb03f 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -130,7 +130,8 @@ Duration vs TimeInterval ---------------------------- The ``times`` module exports two similiar types that are both used to - represent some amount of time: ``Duration`` and ``TimeInterval``. + represent some amount of time: `Duration <#Duration>`_ and + `TimeInterval <#TimeInterval>`_. This section explains how they differ and when one should be prefered over the other (short answer: use ``Duration`` unless support for months and years is needed). @@ -302,9 +303,10 @@ type ## they should never be mutated directly. Doing so is unsafe and will ## result in the ``DateTime`` ending up in an invalid state. ## - ## Instead of mutating the fields directly, use the ``Duration`` - ## and ``TimeInterval`` types for arithmetic and use the ``initDateTime`` - ## procedure for changing a specific field. + ## Instead of mutating the fields directly, use the `Duration <#Duration>`_ + ## and `TimeInterval <#TimeInterval>`_ types for arithmetic and use the + ## `initDateTime proc <#initDateTime,MonthdayRange,Month,int,HourRange,MinuteRange,SecondRange,NanosecondRange,Timezone>`_ + ## for changing a specific field. nanosecond*: NanosecondRange ## The number of nanoseconds after the second, ## in the range 0 to 999_999_999. second*: SecondRange ## The number of seconds after the minute, @@ -334,7 +336,10 @@ type ## ``-3600``). Duration* = object ## Represents a fixed duration of time, meaning a duration - ## that has constant length independent of the context. + ## that has constant length independent of the context. + ## + ## To create a new ``Duration``, use `initDuration proc + ## <#initDuration,int64,int64,int64,int64,int64,int64,int64,int64>`_. seconds: int64 nanosecond: NanosecondRange @@ -348,15 +353,20 @@ type TimeInterval* = object ## \ ## Represents a non-fixed duration of time. Can be used to add and - ## subtract non-fixed time units from a ``DateTime`` or ``Time``. + ## subtract non-fixed time units from a `DateTime <#DateTime>`_ or + ## `Time <#Time>`_. + ## + ## Create a new ``TimeInterval`` with `initTimeInterval proc + ## <#initTimeInterval,int,int,int,int,int,int,int,int,int,int>`_. + ## ## Note that ``TimeInterval`` doesn't represent a fixed duration of time, ## since the duration of some units depend on the context (e.g a year ## can be either 365 or 366 days long). The non-fixed time units are ## years, months, days and week. ## ## Note that ``TimeInterval``'s returned from the ``times`` module are - ## never normalized. If you want to normalize a time unit, ``Duration`` - ## should be used instead. + ## never normalized. If you want to normalize a time unit, + ## `Duration <#Duration>`_ should be used instead. nanoseconds*: int ## The number of nanoseconds microseconds*: int ## The number of microseconds milliseconds*: int ## The number of milliseconds @@ -369,7 +379,7 @@ type years*: int ## The number of years Timezone* = ref object ## \ - ## Timezone interface for supporting ``DateTime``'s of arbritary + ## Timezone interface for supporting `DateTime <#DateTime>`_\s of arbritary ## timezones. The ``times`` module only supplies implementations for the ## systems local time and UTC. zonedTimeFromTimeImpl: proc (x: Time): ZonedTime @@ -451,7 +461,7 @@ proc nanosecond*(time: Time): NanosecondRange = proc initDuration*(nanoseconds, microseconds, milliseconds, seconds, minutes, hours, days, weeks: int64 = 0): Duration = - ## Create a new duration. + ## Create a new `Duration <#Duration>`_. runnableExamples: let dur = initDuration(seconds = 1, milliseconds = 1) doAssert dur.milliseconds == 1 @@ -473,53 +483,72 @@ proc initDuration*(nanoseconds, microseconds, milliseconds, proc weeks*(dur: Duration): int64 {.inline.} = ## Number of whole weeks represented by the duration. + runnableExamples: + let dur = initDuration(weeks = 1, days = 2, hours = 3, minutes = 4) + doAssert dur.weeks == 1 convert(Seconds, Weeks, dur.seconds) proc days*(dur: Duration): int64 {.inline.} = ## Number of whole days represented by the duration. + runnableExamples: + let dur = initDuration(weeks = 1, days = 2, hours = 3, minutes = 4) + doAssert dur.days == 9 convert(Seconds, Days, dur.seconds) -proc minutes*(dur: Duration): int64 {.inline.} = - ## Number of whole minutes represented by the duration. - convert(Seconds, Minutes, dur.seconds) - proc hours*(dur: Duration): int64 {.inline.} = ## Number of whole hours represented by the duration. + runnableExamples: + let dur = initDuration(days = 1, hours = 2, minutes = 3) + doAssert dur.hours == 26 convert(Seconds, Hours, dur.seconds) +proc minutes*(dur: Duration): int64 {.inline.} = + ## Number of whole minutes represented by the duration. + runnableExamples: + let dur = initDuration(days = 1, hours = 2, minutes = 3) + doAssert dur.minutes == 1563 + convert(Seconds, Minutes, dur.seconds) + proc seconds*(dur: Duration): int64 {.inline.} = ## Number of whole seconds represented by the duration. + runnableExamples: + let dur = initDuration(minutes = 10, seconds = 30) + doAssert dur.seconds == 630 dur.seconds proc milliseconds*(dur: Duration): int {.inline.} = ## Number of whole milliseconds represented by the **fractional** ## part of the duration. runnableExamples: - let dur = initDuration(seconds = 1, milliseconds = 1) - doAssert dur.milliseconds == 1 + let dur = initDuration(minutes = 5, seconds = 6, milliseconds = 7, + microseconds = 8, nanoseconds = 9) + doAssert dur.milliseconds == 7 convert(Nanoseconds, Milliseconds, dur.nanosecond) proc microseconds*(dur: Duration): int {.inline.} = ## Number of whole microseconds represented by the **fractional** ## part of the duration. runnableExamples: - let dur = initDuration(seconds = 1, microseconds = 1) - doAssert dur.microseconds == 1 + let dur = initDuration(minutes = 5, seconds = 6, milliseconds = 7, + microseconds = 8, nanoseconds = 9) + doAssert dur.microseconds == 7008 convert(Nanoseconds, Microseconds, dur.nanosecond) proc nanoseconds*(dur: Duration): int {.inline.} = ## Number of whole nanoseconds represented by the **fractional** ## part of the duration. runnableExamples: - let dur = initDuration(seconds = 1, nanoseconds = 1) - doAssert dur.nanoseconds == 1 + let dur = initDuration(minutes = 5, seconds = 6, milliseconds = 7, + microseconds = 8, nanoseconds = 9) + doAssert dur.nanoseconds == 7008009 dur.nanosecond proc fractional*(dur: Duration): Duration {.inline.} = ## The fractional part of duration, as a duration. runnableExamples: - let dur = initDuration(seconds = 1, nanoseconds = 5) - doAssert dur.fractional == initDuration(nanoseconds = 5) + let dur = initDuration(minutes = 5, seconds = 6, milliseconds = 7, + microseconds = 8, nanoseconds = 9) + doAssert dur.fractional == initDuration(milliseconds = 7, microseconds = 8, nanoseconds = 9) initDuration(nanoseconds = dur.nanosecond) proc fromUnix*(unix: int64): Time @@ -551,11 +580,17 @@ proc toWinTime*(t: Time): int64 = proc isLeapYear*(year: int): bool = ## Returns true if ``year`` is a leap year. + runnableExamples: + doAssert isLeapYear(2000) + doAssert not isLeapYear(1900) year mod 4 == 0 and (year mod 100 != 0 or year mod 400 == 0) proc getDaysInMonth*(month: Month, year: int): int = ## Get the number of days in ``month`` of ``year``. # http://www.dispersiondesign.com/articles/time/number_of_days_in_a_month + runnableExamples: + doAssert getDaysInMonth(mFeb, 2000) == 29 + doAssert getDaysInMonth(mFeb, 2001) == 28 case month of mFeb: result = if isLeapYear(year): 29 else: 28 of mApr, mJun, mSep, mNov: result = 30 @@ -563,6 +598,9 @@ proc getDaysInMonth*(month: Month, year: int): int = proc getDaysInYear*(year: int): int = ## Get the number of days in a ``year`` + runnableExamples: + doAssert getDaysInYear(2000) == 366 + doAssert getDaysInYear(2001) == 365 result = 365 + (if isLeapYear(year): 1 else: 0) proc assertValidDate(monthday: MonthdayRange, month: Month, year: int) @@ -609,6 +647,11 @@ proc getDayOfYear*(monthday: MonthdayRange, month: Month, year: int): YeardayRange {.tags: [], raises: [], benign.} = ## Returns the day of the year. ## Equivalent with ``initDateTime(monthday, month, year, 0, 0, 0).yearday``. + runnableExamples: + doAssert getDayOfYear(1, mJan, 2000) == 0 + doAssert getDayOfYear(10, mJan, 2000) == 9 + doAssert getDayOfYear(10, mFeb, 2000) == 40 + assertValidDate monthday, month, year const daysUntilMonth: array[Month, int] = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334] @@ -624,6 +667,10 @@ proc getDayOfWeek*(monthday: MonthdayRange, month: Month, year: int): WeekDay {.tags: [], raises: [], benign.} = ## Returns the day of the week enum from day, month and year. ## Equivalent with ``initDateTime(monthday, month, year, 0, 0, 0).weekday``. + runnableExamples: + doAssert getDayOfWeek(13, mJun, 1990) == dWed + doAssert $getDayOfWeek(13, mJun, 1990) == "Wednesday" + assertValidDate monthday, month, year # 1970-01-01 is a Thursday, we adjust to the previous Monday let days = toEpochday(monthday, month, year) - 3 @@ -670,6 +717,7 @@ proc toParts*(dur: Duration): DurationParts = var dp = toParts(initDuration(weeks = 2, days = 1)) doAssert dp[Days] == 1 doAssert dp[Weeks] == 2 + doAssert dp[Minutes] == 0 dp = toParts(initDuration(days = -1)) doAssert dp[Days] == -1 @@ -766,24 +814,32 @@ proc `<`*(a, b: Duration): bool {.operator.} = runnableExamples: doAssert initDuration(seconds = 1) < initDuration(seconds = 2) doAssert initDuration(seconds = -2) < initDuration(seconds = 1) + doAssert initDuration(seconds = -2).abs < initDuration(seconds = 1).abs == false ltImpl(a, b) proc `<=`*(a, b: Duration): bool {.operator.} = lqImpl(a, b) proc `==`*(a, b: Duration): bool {.operator.} = + runnableExamples: + let + d1 = initDuration(weeks = 1) + d2 = initDuration(days = 7) + doAssert d1 == d2 eqImpl(a, b) proc `*`*(a: int64, b: Duration): Duration {.operator.} = ## Multiply a duration by some scalar. runnableExamples: doAssert 5 * initDuration(seconds = 1) == initDuration(seconds = 5) + doAssert 3 * initDuration(minutes = 45) == initDuration(hours = 2, minutes = 15) normalize[Duration](a * b.seconds, a * b.nanosecond) proc `*`*(a: Duration, b: int64): Duration {.operator.} = ## Multiply a duration by some scalar. runnableExamples: doAssert initDuration(seconds = 1) * 5 == initDuration(seconds = 5) + doAssert initDuration(minutes = 45) * 3 == initDuration(hours = 2, minutes = 15) b * a proc `div`*(a: Duration, b: int64): Duration {.operator.} = @@ -791,18 +847,23 @@ proc `div`*(a: Duration, b: int64): Duration {.operator.} = runnableExamples: doAssert initDuration(seconds = 3) div 2 == initDuration(milliseconds = 1500) + doAssert initDuration(minutes = 45) div 30 == + initDuration(minutes = 1, seconds = 30) doAssert initDuration(nanoseconds = 3) div 2 == initDuration(nanoseconds = 1) let carryOver = convert(Seconds, Nanoseconds, a.seconds mod b) normalize[Duration](a.seconds div b, (a.nanosecond + carryOver) div b) proc initTime*(unix: int64, nanosecond: NanosecondRange): Time = - ## Create a ``Time`` from a unix timestamp and a nanosecond part. + ## Create a `Time <#Time>`_ from a unix timestamp and a nanosecond part. result.seconds = unix result.nanosecond = nanosecond proc `-`*(a, b: Time): Duration {.operator, extern: "ntDiffTime".} = ## Computes the duration between two points in time. + runnableExamples: + doAssert initTime(1000, 100) - initTime(500, 20) == + initDuration(minutes = 8, seconds = 20, nanoseconds = 80) subImpl[Duration](a, b) proc `+`*(a: Time, b: Duration): Time {.operator, extern: "ntAddTime".} = @@ -819,6 +880,8 @@ proc `-`*(a: Time, b: Duration): Time {.operator, extern: "ntSubTime".} = proc `<`*(a, b: Time): bool {.operator, extern: "ntLtTime".} = ## Returns true iff ``a < b``, that is iff a happened before b. + runnableExamples: + doAssert initTime(50, 0) < initTime(99, 0) ltImpl(a, b) proc `<=`*(a, b: Time): bool {.operator, extern: "ntLeTime".} = @@ -1134,7 +1197,7 @@ proc now*(): DateTime {.tags: [TimeEffect], benign.} = proc initTimeInterval*(nanoseconds, microseconds, milliseconds, seconds, minutes, hours, days, weeks, months, years: int = 0): TimeInterval = - ## Creates a new ``TimeInterval``. + ## Creates a new `TimeInterval <#TimeInterval>`_. ## ## This proc doesn't perform any normalization! For example, ## ``initTimeInterval(hours = 24)`` and ``initTimeInterval(days = 1)`` are @@ -1342,7 +1405,7 @@ proc initDateTime*(monthday: MonthdayRange, month: Month, year: int, hour: HourRange, minute: MinuteRange, second: SecondRange, nanosecond: NanosecondRange, zone: Timezone = local()): DateTime = - ## Create a new ``DateTime`` in the specified timezone. + ## Create a new `DateTime <#DateTime>`_ in the specified timezone. runnableExamples: let dt1 = initDateTime(30, mMar, 2017, 00, 00, 00, 00, utc()) doAssert $dt1 == "2017-03-30T00:00:00Z" @@ -1362,7 +1425,7 @@ proc initDateTime*(monthday: MonthdayRange, month: Month, year: int, proc initDateTime*(monthday: MonthdayRange, month: Month, year: int, hour: HourRange, minute: MinuteRange, second: SecondRange, zone: Timezone = local()): DateTime = - ## Create a new ``DateTime`` in the specified timezone. + ## Create a new `DateTime <#DateTime>`_ in the specified timezone. runnableExamples: let dt1 = initDateTime(30, mMar, 2017, 00, 00, 00, utc()) doAssert $dt1 == "2017-03-30T00:00:00Z" @@ -1663,7 +1726,10 @@ type Lit TimeFormat* = object ## Represents a format for parsing and printing - ## time types. + ## time types. + ## + ## To create a new ``TimeFormat`` use `initTimeFormat proc + ## <#initTimeFormat,string>`_. patterns: seq[byte] ## \ ## Contains the patterns encoded as bytes. ## Literal values are encoded in a special way. From 85f2ab1c43e846ec99014d8f0901f0ea65876908 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Mon, 11 Feb 2019 22:18:55 -0800 Subject: [PATCH 27/50] travis:upgrade to xenial (trusty end of life is april 2019) (#10643) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0e55d3affc..7ab45b1c79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ sudo: false language: c -dist: trusty +dist: xenial matrix: include: From 33ddc2105779938da7f8f85ec97704841f9a8fee Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Tue, 12 Feb 2019 03:22:04 -0300 Subject: [PATCH 28/50] Lowercase ext before querying the mimedb on mimetypes module, change isMainModule to runnableExamples (#10644) --- lib/pure/mimetypes.nim | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/lib/pure/mimetypes.nim b/lib/pure/mimetypes.nim index 95c51487a5..57ea825270 100644 --- a/lib/pure/mimetypes.nim +++ b/lib/pure/mimetypes.nim @@ -9,6 +9,8 @@ ## This module implements a mimetypes database import strtabs +from strutils import startsWith, toLowerAscii, strip + type MimeDB* = object mimes: StringTableRef @@ -1878,37 +1880,53 @@ const mimes* = { "~": "application/x-trash" } -from strutils import startsWith -proc newMimetypes*(): MimeDB = +func newMimetypes*(): MimeDB = ## Creates a new Mimetypes database. The database will contain the most ## common mimetypes. result.mimes = mimes.newStringTable() -proc getMimetype*(mimedb: MimeDB, ext: string, default = "text/plain"): string = +func getMimetype*(mimedb: MimeDB, ext: string, default = "text/plain"): string = ## Gets mimetype which corresponds to ``ext``. Returns ``default`` if ``ext`` ## could not be found. ``ext`` can start with an optional dot which is ignored. + ## ``ext`` is lowercased before querying ``mimedb``. if ext.startsWith("."): - result = mimedb.mimes.getOrDefault(ext.substr(1)) + result = mimedb.mimes.getOrDefault(ext.toLowerAscii.substr(1)) else: - result = mimedb.mimes.getOrDefault(ext) + result = mimedb.mimes.getOrDefault(ext.toLowerAscii()) if result == "": return default -proc getExt*(mimedb: MimeDB, mimetype: string, default = "txt"): string = +func getExt*(mimedb: MimeDB, mimetype: string, default = "txt"): string = ## Gets extension which corresponds to ``mimetype``. Returns ``default`` if ## ``mimetype`` could not be found. Extensions are returned without the - ## leading dot. + ## leading dot. ``mimetype`` is lowercased before querying ``mimedb``. result = default + let mimeLowered = mimetype.toLowerAscii() for e, m in mimedb.mimes: - if m == mimetype: + if m == mimeLowered: result = e -proc register*(mimedb: var MimeDB, ext: string, mimetype: string) = +func register*(mimedb: var MimeDB, ext: string, mimetype: string) = ## Adds ``mimetype`` to the ``mimedb``. - mimedb.mimes[ext] = mimetype + ## ``mimetype`` and ``ext`` are lowercased before registering on ``mimedb``. + assert ext.strip.len > 0, "ext argument can not be empty string" + assert mimetype.strip.len > 0, "mimetype argument can not be empty string" + mimedb.mimes[ext.toLowerAscii()] = mimetype.toLowerAscii() -when isMainModule: +runnableExamples: var m = newMimetypes() assert m.getMimetype("mp4") == "video/mp4" assert m.getExt("text/html") == "html" + ## Values can be uppercase too. + assert m.getMimetype("MP4") == "video/mp4" + assert m.getExt("TEXT/HTML") == "html" + ## If values are invalid then ``default`` is returned. + assert m.getMimetype("INVALID") == "text/plain" + assert m.getExt("INVALID/NONEXISTENT") == "txt" + assert m.getMimetype("") == "text/plain" + assert m.getExt("") == "txt" + ## Register new Mimetypes. + m.register(ext="fakext", mimetype="text/fakelang") + assert m.getMimetype("fakext") == "text/fakelang" + assert m.getMimetype("FaKeXT") == "text/fakelang" From c59fa80367b25c83c0e35714a4e15862b704764e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20D=C3=B6ring?= Date: Tue, 12 Feb 2019 08:10:40 +0100 Subject: [PATCH 29/50] deprecated list comprehension (#10636) --- lib/pure/sugar.nim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pure/sugar.nim b/lib/pure/sugar.nim index 53c31e8c90..c4c9912142 100644 --- a/lib/pure/sugar.nim +++ b/lib/pure/sugar.nim @@ -123,11 +123,11 @@ macro `->`*(p, b: untyped): untyped = result = createProcType(p, b) type ListComprehension = object -var lc*: ListComprehension +var lc* {.deprecated.}: ListComprehension -template `|`*(lc: ListComprehension, comp: untyped): untyped = lc +template `|`*(lc: ListComprehension, comp: untyped): untyped {.deprecated.} = lc -macro `[]`*(lc: ListComprehension, comp, typ: untyped): untyped = +macro `[]`*(lc: ListComprehension, comp, typ: untyped): untyped {.deprecated.} = ## List comprehension, returns a sequence. `comp` is the actual list ## comprehension, for example ``x | (x <- 1..10, x mod 2 == 0)``. `typ` is ## the type that will be stored inside the result seq. @@ -139,6 +139,7 @@ macro `[]`*(lc: ListComprehension, comp, typ: untyped): untyped = ## const n = 20 ## echo lc[(x,y,z) | (x <- 1..n, y <- x..n, z <- y..n, x*x + y*y == z*z), ## tuple[a,b,c: int]] + ## **Deprecated since version 0.19.9** expectLen(comp, 3) expectKind(comp, nnkInfix) From cf5812aa9f9089f40275ae4d162f8a715635aad8 Mon Sep 17 00:00:00 2001 From: alaviss Date: Tue, 12 Feb 2019 14:17:39 +0700 Subject: [PATCH 30/50] nimsuggest: only log when logging is enabled (#10646) fixes #6199 --- nimsuggest/nimsuggest.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index 1b5e8326d7..ef11cc9e25 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -520,7 +520,7 @@ proc mainCommand(graph: ModuleGraph) = # do not stop after the first error: conf.errorMax = high(int) # do not print errors, but log them - conf.writelnHook = proc (s: string) = log(s) + conf.writelnHook = myLog conf.structuredErrorHook = nil # compile the project before showing any input so that we already @@ -661,7 +661,7 @@ else: # do not stop after the first error: conf.errorMax = high(int) # do not print errors, but log them - conf.writelnHook = proc (s: string) = log(s) + conf.writelnHook = myLog conf.structuredErrorHook = nil # compile the project before showing any input so that we already From 1d1360496f1fdebb1370ae491c988d2245a56da9 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Tue, 12 Feb 2019 08:23:24 +0100 Subject: [PATCH 31/50] Fix codegen problem with strict C++ compilers (#10639) Since tyCString is convertible to a tyPointer we must be extra careful to emit a cast to (void*) in order to appease clang++. Reported by masnagam on the Nim forum. --- compiler/semfold.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/semfold.nim b/compiler/semfold.nim index f0b03018fb..2468719286 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -465,7 +465,7 @@ proc foldConv(n, a: PNode; g: ModuleGraph; check = false): PNode = else: result = a result.typ = n.typ - of tyOpenArray, tyVarargs, tyProc: + of tyOpenArray, tyVarargs, tyProc, tyPointer: discard else: result = a From 0e5d4f10364d1f8efae2e9474f70bfeb6f5f1850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20D=C3=B6ring?= Date: Tue, 12 Feb 2019 08:27:38 +0100 Subject: [PATCH 32/50] reduce debug output (#10638) --- compiler/astalgo.nim | 121 ++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 58 deletions(-) diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim index 60eecbdc5d..48a651632b 100644 --- a/compiler/astalgo.nim +++ b/compiler/astalgo.nim @@ -238,17 +238,6 @@ proc symToYamlAux(conf: ConfigRef; n: PSym, marker: var IntSet, proc typeToYamlAux(conf: ConfigRef; n: PType, marker: var IntSet, indent, maxRecDepth: int): Rope -proc ropeConstr(indent: int, c: openArray[Rope]): Rope = - # array of (name, value) pairs - var istr = rspaces(indent + 2) - result = rope("{") - var i = 0 - while i <= high(c): - if i > 0: add(result, ",") - addf(result, "$N$1\"$2\": $3", [istr, c[i], c[i + 1]]) - inc(i, 2) - addf(result, "$N$1}", [rspaces(indent)]) - proc symToYamlAux(conf: ConfigRef; n: PSym, marker: var IntSet, indent: int, maxRecDepth: int): Rope = if n == nil: @@ -257,51 +246,60 @@ proc symToYamlAux(conf: ConfigRef; n: PSym, marker: var IntSet, indent: int, result = "\"$1\"" % [rope(n.name.s)] else: var ast = treeToYamlAux(conf, n.ast, marker, indent + 2, maxRecDepth - 1) - result = ropeConstr(indent, [rope("kind"), - makeYamlString($n.kind), - rope("name"), makeYamlString(n.name.s), #rope("typ"), typeToYamlAux(conf, n.typ, marker, # indent + 2, maxRecDepth - 1), - rope("info"), lineInfoToStr(conf, n.info), - rope("flags"), flagsToStr(n.flags), - rope("magic"), makeYamlString($n.magic), - rope("ast"), ast, rope("options"), - flagsToStr(n.options), rope("position"), - rope(n.position), - rope("k"), makeYamlString($n.loc.k), - rope("storage"), makeYamlString($n.loc.storage), - rope("flags"), makeYamlString($n.loc.flags), - rope("r"), n.loc.r, - rope("lode"), treeToYamlAux(conf, n.loc.lode, marker, indent + 2, maxRecDepth - 1) - ]) + let istr = rspaces(indent + 2) + result = rope("{") + addf(result, "$N$1\"kind\": $2", [istr, makeYamlString($n.kind)]) + addf(result, "$N$1\"name\": $2", [istr, makeYamlString(n.name.s)]) + addf(result, "$N$1\"typ\": $2", [istr, typeToYamlAux(conf, n.typ, marker, indent + 2, maxRecDepth - 1)]) + if conf != nil: + # if we don't pass the config, we probably don't care about the line info + addf(result, "$N$1\"info\": $2", [istr, lineInfoToStr(conf, n.info)]) + if card(n.flags) > 0: + addf(result, "$N$1\"flags\": $2", [istr, flagsToStr(n.flags)]) + addf(result, "$N$1\"magic\": $2", [istr, makeYamlString($n.magic)]) + addf(result, "$N$1\"ast\": $2", [istr, ast]) + addf(result, "$N$1\"options\": $2", [istr, flagsToStr(n.options)]) + addf(result, "$N$1\"position\": $2", [istr, rope(n.position)]) + addf(result, "$N$1\"k\": $2", [istr, makeYamlString($n.loc.k)]) + addf(result, "$N$1\"storage\": $2", [istr, makeYamlString($n.loc.storage)]) + if card(n.loc.flags) > 0: + addf(result, "$N$1\"flags\": $2", [istr, makeYamlString($n.loc.flags)]) + addf(result, "$N$1\"r\": $2", [istr, n.loc.r]) + addf(result, "$N$1\"lode\": $2", [istr, treeToYamlAux(conf, n.loc.lode, marker, indent + 2, maxRecDepth - 1)]) + addf(result, "$N$1}", [rspaces(indent)]) proc typeToYamlAux(conf: ConfigRef; n: PType, marker: var IntSet, indent: int, maxRecDepth: int): Rope = + var sonsRope: Rope if n == nil: - result = rope("null") + sonsRope = rope("null") elif containsOrIncl(marker, n.id): - result = "\"$1 @$2\"" % [rope($n.kind), rope( + sonsRope = "\"$1 @$2\"" % [rope($n.kind), rope( strutils.toHex(cast[ByteAddress](n), sizeof(n) * 2))] else: if sonsLen(n) > 0: - result = rope("[") + sonsRope = rope("[") for i in countup(0, sonsLen(n) - 1): - if i > 0: add(result, ",") - addf(result, "$N$1$2", [rspaces(indent + 4), typeToYamlAux(conf, n.sons[i], + if i > 0: add(sonsRope, ",") + addf(sonsRope, "$N$1$2", [rspaces(indent + 4), typeToYamlAux(conf, n.sons[i], marker, indent + 4, maxRecDepth - 1)]) - addf(result, "$N$1]", [rspaces(indent + 2)]) + addf(sonsRope, "$N$1]", [rspaces(indent + 2)]) else: - result = rope("null") - result = ropeConstr(indent, [rope("kind"), - makeYamlString($n.kind), - rope("sym"), symToYamlAux(conf, n.sym, marker, - indent + 2, maxRecDepth - 1), rope("n"), treeToYamlAux(conf, n.n, marker, - indent + 2, maxRecDepth - 1), rope("flags"), flagsToStr(n.flags), - rope("callconv"), - makeYamlString(CallingConvToStr[n.callConv]), - rope("size"), rope(n.size), - rope("align"), rope(n.align), - rope("sons"), result]) + sonsRope = rope("null") + + let istr = rspaces(indent + 2) + result = rope("{") + addf(result, "$N$1\"kind\": $2", [istr, makeYamlString($n.kind)]) + addf(result, "$N$1\"sym\": $2", [istr, symToYamlAux(conf, n.sym, marker, indent + 2, maxRecDepth - 1)]) + addf(result, "$N$1\"n\": $2", [istr, treeToYamlAux(conf, n.n, marker, indent + 2, maxRecDepth - 1)]) + if card(n.flags) > 0: + addf(result, "$N$1\"flags\": $2", [istr, flagsToStr(n.flags)]) + addf(result, "$N$1\"callconv\": $2", [istr, makeYamlString(CallingConvToStr[n.callConv])]) + addf(result, "$N$1\"size\": $2", [istr, rope(n.size)]) + addf(result, "$N$1\"align\": $2", [istr, rope(n.align)]) + addf(result, "$N$1\"sons\": $2", [istr, sonsRope]) proc treeToYamlAux(conf: ConfigRef; n: PNode, marker: var IntSet, indent: int, maxRecDepth: int): Rope = @@ -311,7 +309,8 @@ proc treeToYamlAux(conf: ConfigRef; n: PNode, marker: var IntSet, indent: int, var istr = rspaces(indent + 2) result = "{$N$1\"kind\": $2" % [istr, makeYamlString($n.kind)] if maxRecDepth != 0: - addf(result, ",$N$1\"info\": $2", [istr, lineInfoToStr(conf, n.info)]) + if conf != nil: + addf(result, ",$N$1\"info\": $2", [istr, lineInfoToStr(conf, n.info)]) case n.kind of nkCharLit..nkInt64Lit: addf(result, ",$N$1\"intVal\": $2", [istr, rope(n.intVal)]) @@ -362,8 +361,8 @@ proc debugType(conf: ConfigRef; n: PType, maxRecDepth=100): Rope = add(result, " ") add(result, n.sym.name.s) if n.kind in IntegralTypes and n.n != nil: - add(result, ", node: ") - add(result, debugTree(conf, n.n, 2, maxRecDepth-1, renderType=true)) + add(result, ", n: ") + add(result, debugTree(conf, n.n, 2, maxRecDepth-1, renderType=false)) if (n.kind != tyString) and (sonsLen(n) > 0) and maxRecDepth != 0: add(result, "(") for i in countup(0, sonsLen(n) - 1): @@ -373,7 +372,7 @@ proc debugType(conf: ConfigRef; n: PType, maxRecDepth=100): Rope = else: add(result, debugType(conf, n.sons[i], maxRecDepth-1)) if n.kind == tyObject and n.n != nil: - add(result, ", node: ") + add(result, ", n: ") add(result, debugTree(conf, n.n, 2, maxRecDepth-1, renderType=true)) add(result, ")") @@ -387,9 +386,11 @@ proc debugTree(conf: ConfigRef; n: PNode, indent: int, maxRecDepth: int; [istr, makeYamlString($n.kind)] when defined(useNodeIds): addf(result, ",$N$1\"id\": $2", [istr, rope(n.id)]) - addf(result, ",$N$1\"info\": $2", [istr, lineInfoToStr(conf, n.info)]) + if conf != nil: + addf(result, ",$N$1\"info\": $2", [istr, lineInfoToStr(conf, n.info)]) if maxRecDepth != 0: - addf(result, ",$N$1\"flags\": $2", [istr, rope($n.flags)]) + if card(n.flags) > 0: + addf(result, ",$N$1\"flags\": $2", [istr, rope($n.flags)]) case n.kind of nkCharLit..nkUInt64Lit: addf(result, ",$N$1\"intVal\": $2", [istr, rope(n.intVal)]) @@ -400,15 +401,19 @@ proc debugTree(conf: ConfigRef; n: PNode, indent: int, maxRecDepth: int; addf(result, ",$N$1\"strVal\": $2", [istr, makeYamlString(n.strVal)]) of nkSym: let s = n.sym - addf(result, ",$N$1\"sym\": $2_$3 k: $4 storage: $5 flags: $6 r: $7", - [istr, rope(s.name.s), rope(s.id), - rope($s.loc.k), - rope($s.loc.storage), - rope($s.loc.flags), - s.loc.r - ]) -# [istr, symToYaml(conf, n.sym, indent, maxRecDepth), -# rope(n.sym.id)]) + var symStr = "" + symStr.add "\"kind\": " + symStr.add $s.kind + symStr.add ", \"name\": " + symStr.add s.name.s + symStr.add ", \"id\": " + symStr.add s.id + if s.kind in {skField, skEnumField, skParam}: + symStr.add ", \"position\": " + symStr.add s.position + addf(result, ",$N$1\"sym\": {$2}", [ + istr, rope(symStr)]) + if renderType and n.sym.typ != nil: addf(result, ",$N$1\"typ\": $2", [istr, debugType(conf, n.sym.typ, 2)]) of nkIdent: From cc507668cbd76af0f5e1c9a36c43c1a23eeb00fb Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Mon, 11 Feb 2019 23:30:53 -0800 Subject: [PATCH 33/50] fix travis: add set -e in script (#10631) --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7ab45b1c79..c202a16546 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,10 +45,12 @@ before_script: - set +e # prevents breaking after_failure script: + - set -e - echo "travis_fold:start:nim_c_koch" - nim c koch - echo "travis_fold:end:nim_c_koch" - ./koch runCI + - set +e before_deploy: # Make https://nim-lang.github.io/Nim work the same as https://nim-lang.github.io/Nim/overview.html From bdc150adffccd339dd80e837d5d527206f651e88 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Tue, 12 Feb 2019 00:33:20 -0800 Subject: [PATCH 34/50] randomize: added doAssert(seed!=0) to avoid invalid (non-random) behavior (#10635) --- lib/pure/random.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pure/random.nim b/lib/pure/random.nim index 85466ed9ef..86db7da497 100644 --- a/lib/pure/random.nim +++ b/lib/pure/random.nim @@ -513,6 +513,7 @@ proc initRand*(seed: int64): Rand = let now = getTime() var r2 = initRand(now.toUnix * 1_000_000_000 + now.nanosecond) + doAssert seed != 0 # 0 causes `rand(int)` to always return 0 for example. result.a0 = ui(seed shr 16) result.a1 = ui(seed and 0xffff) discard next(result) From 6870345cd2af461d49159ad453c5f6437752d096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20D=C3=B6ring?= Date: Tue, 12 Feb 2019 22:00:31 +0100 Subject: [PATCH 35/50] 32 bit fixes (#10608) --- bin/nim-gdb | 3 + build_all.sh | 1 - compiler/ast.nim | 9 ++- compiler/ccgexprs.nim | 5 ++ compiler/evaltempl.nim | 7 +-- compiler/pragmas.nim | 13 +++-- compiler/semmagic.nim | 14 ++++- compiler/semtempl.nim | 4 ++ compiler/suggest.nim | 2 +- koch.nim | 3 +- lib/pure/math.nim | 2 +- testament/specs.nim | 3 + tests/concepts/texplain.nim | 12 ++-- tests/converter/tgenericconverter2.nim | 36 +++++++----- tests/enum/tenummix.nim | 4 +- tests/errmsgs/tunknown_named_parameter.nim | 3 + tests/generics/trtree.nim | 2 + tests/misc/tradix.nim | 5 +- tests/misc/tsizeof.nim | 30 +++++++++- tests/objects/tobject3.nim | 28 +-------- tests/stdlib/tosproc.nim | 8 +-- tests/system/t7894.nim | 1 + tests/system/talloc2.nim | 68 +++++++++++----------- tests/types/tfinalobj.nim | 20 +------ tests/vm/tvmops.nim | 5 ++ tests/vm/tzero_extend.nim | 12 ++-- 26 files changed, 165 insertions(+), 135 deletions(-) diff --git a/bin/nim-gdb b/bin/nim-gdb index e7b41094df..9d6f462bb8 100755 --- a/bin/nim-gdb +++ b/bin/nim-gdb @@ -3,6 +3,9 @@ # Exit if anything fails set -e +which nim > /dev/null || (echo "nim not in PATH"; exit 1) +which gdb > /dev/null || (echo "gdb not in PATH"; exit 1) + # Find out where the pretty printer Python module is NIM_SYSROOT=$(dirname $(dirname $(readlink -e $(which nim)))) GDB_PYTHON_MODULE_PATH="$NIM_SYSROOT/tools/nim-gdb.py" diff --git a/build_all.sh b/build_all.sh index 0706dcaf2b..333814d62d 100644 --- a/build_all.sh +++ b/build_all.sh @@ -27,7 +27,6 @@ build_nim_csources(){ [ -f $nim_csources ] || echo_run build_nim_csources # Note: if fails, may need to `cd csources && git pull` -# see D20190115T162028 echo_run bin/nim c --skipUserCfg --skipParentCfg koch echo_run ./koch boot -d:release diff --git a/compiler/ast.nim b/compiler/ast.nim index 3146722cb9..fbe6132b37 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -271,6 +271,10 @@ type # language; for interfacing with Objective C sfDiscardable, # returned value may be discarded implicitly sfOverriden, # proc is overriden + sfCallSideLineinfo# A flag for template symbols to tell the + # compiler it should use line information from + # the calling side of the macro, not from the + # implementation. sfGenSym # symbol is 'gensym'ed; do not add to symbol table TSymFlags* = set[TSymFlag] @@ -1265,7 +1269,10 @@ proc `$`*(x: TLockLevel): string = else: result = $int16(x) proc `$`*(s: PSym): string = - result = s.name.s & "@" & $s.id + if s != nil: + result = s.name.s & "@" & $s.id + else: + result = "" proc newType*(kind: TTypeKind, owner: PSym): PType = new(result) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index fb2fd89a36..8ccca98131 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -1997,6 +1997,11 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) = of mSizeOf: let t = e.sons[1].typ.skipTypes({tyTypeDesc}) putIntoDest(p, d, e, "((NI)sizeof($1))" % [getTypeDesc(p.module, t)]) + of mAlignOf: + let t = e.sons[1].typ.skipTypes({tyTypeDesc}) + if not p.module.compileToCpp: + p.module.includeHeader("") + putIntoDest(p, d, e, "((NI)alignof($1))" % [getTypeDesc(p.module, t)]) of mChr: genSomeCast(p, e, d) of mOrd: genOrd(p, e, d) of mLengthArray, mHigh, mLengthStr, mLengthSeq, mLengthOpenArray: diff --git a/compiler/evaltempl.nim b/compiler/evaltempl.nim index 0f9220102b..43c038270e 100644 --- a/compiler/evaltempl.nim +++ b/compiler/evaltempl.nim @@ -186,9 +186,9 @@ proc evalTemplate*(n: PNode, tmpl, genSymOwner: PSym; renderTree(result, {renderNoComments})) else: result = copyNode(body) - #ctx.instLines = body.kind notin {nkStmtList, nkStmtListExpr, - # nkBlockStmt, nkBlockExpr} - #if ctx.instLines: result.info = n.info + ctx.instLines = sfCallSideLineinfo in tmpl.flags + if ctx.instLines: + result.info = n.info for i in countup(0, safeLen(body) - 1): evalTemplateAux(body.sons[i], args, ctx, result) result.flags.incl nfFromTemplate @@ -196,4 +196,3 @@ proc evalTemplate*(n: PNode, tmpl, genSymOwner: PSym; #if ctx.debugActive: # echo "instantion of ", renderTree(result, {renderIds}) dec(conf.evalTemplateCounter) - diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 03c9127af0..d12f5f5d1a 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -803,12 +803,15 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, of wSize: if sym.typ == nil: invalidPragma(c, it) var size = expectIntLit(c, it) - if not isPowerOfTwo(size) or size <= 0 or size > 8: - localError(c.config, it.info, "size may only be 1, 2, 4 or 8") - else: + case size + of 1, 2, 4, 8: sym.typ.size = size - # TODO, this is not correct - sym.typ.align = int16(size) + if size == 8 and c.config.target.targetCPU == cpuI386: + sym.typ.align = 4 + else: + sym.typ.align = int16(size) + else: + localError(c.config, it.info, "size may only be 1, 2, 4 or 8") of wNodecl: noVal(c, it) incl(sym.loc.flags, lfNoDecl) diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim index 6e5563d69d..77286393ec 100644 --- a/compiler/semmagic.nim +++ b/compiler/semmagic.nim @@ -353,9 +353,17 @@ proc magicsAfterOverloadResolution(c: PContext, n: PNode, localError(c.config, n.info, "cannot evaluate 'sizeof' because its type is not defined completely, type: " & n[1].typ.typeToString) result = n of mAlignOf: - result = newIntNode(nkIntLit, getAlign(c.config, n[1].typ)) - result.info = n.info - result.typ = n.typ + # this is 100% analog to mSizeOf, could be made more dry. + let align = getAlign(c.config, n[1].typ) + if align == szUnknownSize: + result = n + elif align >= 0: + result = newIntNode(nkIntLit, align) + result.info = n.info + result.typ = n.typ + else: + localError(c.config, n.info, "cannot evaluate 'alignof' because its type is not defined completely, type: " & n[1].typ.typeToString) + result = n of mOffsetOf: var dotExpr: PNode diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index d920a54b8a..f180b5373a 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -558,6 +558,10 @@ proc semTemplateDef(c: PContext, n: PNode): PNode = incl(s.flags, sfGlobal) else: s = semIdentVis(c, skTemplate, n.sons[0], {}) + + if s.owner != nil and s.owner.name.s == "system" and s.name.s in ["!=", ">=", ">", "incl", "excl", "in", "notin", "isnot"]: + incl(s.flags, sfCallSideLineinfo) + styleCheckDef(c.config, s) onDef(n[0].info, s) # check parameter list: diff --git a/compiler/suggest.nim b/compiler/suggest.nim index 70a085bdf7..d501acd466 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -495,7 +495,7 @@ proc suggestSym*(conf: ConfigRef; info: TLineInfo; s: PSym; usageSym: var PSym; proc extractPragma(s: PSym): PNode = if s.kind in routineKinds: result = s.ast[pragmasPos] - elif s.kind in {skType, skVar, skLet}: + elif s.kind in {skType, skVar, skLet} and s.ast[0].kind == nkPragmaExpr: # s.ast = nkTypedef / nkPragmaExpr / [nkSym, nkPragma] result = s.ast[0][1] doAssert result == nil or result.kind == nkPragma diff --git a/koch.nim b/koch.nim index 253352c220..5deda5ecd4 100644 --- a/koch.nim +++ b/koch.nim @@ -299,9 +299,8 @@ proc boot(args: string) = var extraOption = "" if i == 0: extraOption.add " --skipUserCfg --skipParentCfg" - # Note(D20190115T162028:here): the configs are skipped for bootstrap + # The configs are skipped for bootstrap # (1st iteration) to prevent newer flags from breaking bootstrap phase. - # fixes #10030. let ret = execCmdEx(nimStart & " --version") doAssert ret.exitCode == 0 let version = ret.output.splitLines[0] diff --git a/lib/pure/math.nim b/lib/pure/math.nim index 526ddbbb2e..f94da043a5 100644 --- a/lib/pure/math.nim +++ b/lib/pure/math.nim @@ -1185,7 +1185,7 @@ when isMainModule: doAssert floorMod(-8.5, 3.0) ==~ 0.5 block: # log - doAssert log(4.0, 3.0) == ln(4.0) / ln(3.0) + doAssert log(4.0, 3.0) ==~ ln(4.0) / ln(3.0) doAssert log2(8.0'f64) == 3.0'f64 doAssert log2(4.0'f64) == 2.0'f64 doAssert log2(2.0'f64) == 1.0'f64 diff --git a/testament/specs.nim b/testament/specs.nim index bfc6b051ed..96b02746bf 100644 --- a/testament/specs.nim +++ b/testament/specs.nim @@ -206,6 +206,9 @@ proc parseSpec*(filename: string): TSpec = if isTravis: result.err = reDisabled of "appveyor": if isAppVeyor: result.err = reDisabled + of "32bit": + if sizeof(int) == 4: + result.err = reDisabled else: result.parseErrors.addLine "cannot interpret as a bool: ", e.value of "cmd": diff --git a/tests/concepts/texplain.nim b/tests/concepts/texplain.nim index ac0c972f52..4ec8487329 100644 --- a/tests/concepts/texplain.nim +++ b/tests/concepts/texplain.nim @@ -65,14 +65,14 @@ expression: f(y) ''' errormsg: "type mismatch: got " line: 138 + + disabled: 32bit """ - - - - - - +# disabled on 32 bit, because the order of suggested alternatives ``r`` differs +# proc r[T](a: SomeNumber; b: T; c: auto) +# proc r(i: string): int +# proc r(o: RegularConcept): int diff --git a/tests/converter/tgenericconverter2.nim b/tests/converter/tgenericconverter2.nim index 017651a6ba..6d1d3d8595 100644 --- a/tests/converter/tgenericconverter2.nim +++ b/tests/converter/tgenericconverter2.nim @@ -1,6 +1,8 @@ # bug #3799 -discard """ -output: ''' + +import strutils + +const output = splitLines(""" 00000000000000000000000000000000000000000 00000000000001111111111111110000000000000 00000000001111111111111111111110000000000 @@ -28,11 +30,7 @@ output: ''' 00000000111111111111111111111111100000000 00000000000111111111111111111100000000000 00000000000000111111111111100000000000000 -''' -""" - - -import macros +""") const nmax = 500 @@ -63,19 +61,25 @@ proc julia*[T](z0, c: Complex[T], er2: T, nmax: int): int = template dendriteFractal*[T](z0: Complex[T], er2: T, nmax: int): int = julia(z0, (T(0.0), T(1.0)), er2, nmax) -iterator stepIt[T](start, step: T, iterations: int): T = +iterator stepIt[T](start, step: T, iterations: int): (int, T) = for i in 0 .. iterations: - yield start + T(i) * step + yield (i, start + T(i) * step) +var errors = 0 let c = (0.36237, 0.32) -for y in stepIt(2.0, -0.0375 * 4, 107 div 4): +for j, y in stepIt(2.0, -0.0375 * 4, 107 div 4): var row = "" - for x in stepIt(-2.0, 0.025 * 4, 160 div 4): + for i, x in stepIt(-2.0, 0.025 * 4, 160 div 4): #let n = julia((x, y), c, 4.0, nmax) ### this works let n = dendriteFractal((x, y), 4.0, nmax) - if n < nmax: - row.add($(n mod 10)) - else: - row.add(' ') - echo row + let c = char(int('0') + n mod 10) + let e = output[j][i] # expected + if c != e: + errors += 1 + row.add(c) + + # Printing aparently makes the test fail when joined. + # echo row + +doAssert errors < 10, "total errors: " & $errors diff --git a/tests/enum/tenummix.nim b/tests/enum/tenummix.nim index c7db4e0560..8c306bae10 100644 --- a/tests/enum/tenummix.nim +++ b/tests/enum/tenummix.nim @@ -1,7 +1,7 @@ discard """ - tfile: "tenummix.nim" - tline: 11 errormsg: "type mismatch" + file: "tenummix.nim" + line: 11 """ type diff --git a/tests/errmsgs/tunknown_named_parameter.nim b/tests/errmsgs/tunknown_named_parameter.nim index 8a3bcaf03b..3051787ea0 100644 --- a/tests/errmsgs/tunknown_named_parameter.nim +++ b/tests/errmsgs/tunknown_named_parameter.nim @@ -16,9 +16,12 @@ proc rsplit(s: string; sep: string; maxsplit: int = -1): seq[string] expression: rsplit("abc:def", {':'}, maxsplits = 1) ''' +disabled: 32bit """ # bug #8043 +# disabled on 32 bit systems because the order of suggested proc alternatives is different. + import strutils "abc:def".rsplit({':'}, maxsplits = 1) diff --git a/tests/generics/trtree.nim b/tests/generics/trtree.nim index 6ec1c8f6f8..f14335154f 100644 --- a/tests/generics/trtree.nim +++ b/tests/generics/trtree.nim @@ -3,8 +3,10 @@ discard """ [0, 0]''' target: "c" joinable: false +disabled: 32bit """ +# this test wasn't written for 32 bit # don't join because the code is too messy. # Nim RTree and R*Tree implementation diff --git a/tests/misc/tradix.nim b/tests/misc/tradix.nim index 5be89530fc..1773a96098 100644 --- a/tests/misc/tradix.nim +++ b/tests/misc/tradix.nim @@ -246,6 +246,9 @@ proc main() = r: PRadixNode = nil for x in items(numbers): echo testOrIncl(r, x) - for x in elements(r): echo(x) + for x in elements(r): + # ByteAddress being defined as a signed integer cases trouble + # exactly here + echo(cast[uint](x)) main() diff --git a/tests/misc/tsizeof.nim b/tests/misc/tsizeof.nim index 25c566171c..f2bed47436 100644 --- a/tests/misc/tsizeof.nim +++ b/tests/misc/tsizeof.nim @@ -279,6 +279,11 @@ testinstance: InheritanceC {.objectconfig.} = object of InheritanceB c: char + # from issue 4763 + GenericObject[T] = object + a: int32 + b: T + #Float128Test = object # a: byte # b: float128 @@ -298,6 +303,7 @@ testinstance: var f : PaddingAfterBranch var g : RecursiveStuff var ro : RootObj + var go : GenericObject[int64] var e1: Enum1 @@ -311,7 +317,7 @@ testinstance: testAlign(SimpleAlignment) - testSizeAlignOf(t,a,b,c,d,e,f,g,ro, e1, e2, e4, e8, eoa, eob) + testSizeAlignOf(t,a,b,c,d,e,f,g,ro,go, e1, e2, e4, e8, eoa, eob) when not defined(cpp): type @@ -414,6 +420,28 @@ type doAssert sizeof(MixedBitsize) == 12 +########################################## +# bug #9794 +########################################## + +type + imported_double {.importc: "double".} = object + + Pod = object + v* : imported_double + seed*: int32 + + Pod2 = tuple[v: imported_double, seed: int32] + +proc foobar() = + testAlign(Pod) + testSize(Pod) + testAlign(Pod2) + testSize(Pod2) + doAssert sizeof(Pod) == sizeof(Pod2) + doAssert alignof(Pod) == alignof(Pod2) +foobar() + if failed: quit("FAIL") else: diff --git a/tests/objects/tobject3.nim b/tests/objects/tobject3.nim index a24a48c8bf..0a3df02ea9 100644 --- a/tests/objects/tobject3.nim +++ b/tests/objects/tobject3.nim @@ -1,10 +1,7 @@ discard """ output: '''TBar2 TFoo -16 -12 -16 -12''' +''' """ ## XXX this output needs to be adapated for VCC which produces different results. @@ -67,29 +64,6 @@ var aa = makeWindow() thisCausesError(dd, aa) -# bug #4763 -type - testObject_1 = object - size: int32 - value: int64 - - testObject_2 {.packed.} = object - size: int32 - value: int64 - - testObject_3[T] = object - size: int32 - value: T - - testObject_4 {.packed.} [T] = object - size: int32 - value: T - -echo sizeof(testObject_1) -echo sizeof(testObject_2) -echo sizeof(testObject_3[int64]) -echo sizeof(testObject_4[int64]) - # bug #5892 type Foo6 = distinct array[4, float32] diff --git a/tests/stdlib/tosproc.nim b/tests/stdlib/tosproc.nim index b8d3be9bbf..363de90967 100644 --- a/tests/stdlib/tosproc.nim +++ b/tests/stdlib/tosproc.nim @@ -48,10 +48,10 @@ when defined(case_testfile): # compiled test file for child process else: import os, osproc, strutils, posix + const nim = getCurrentCompilerExe() block execShellCmdTest: ## first, compile child program - const nim = getCurrentCompilerExe() const sourcePath = currentSourcePath() let output = buildDir / "D20190111T024543".addFileExt(ExeExt) let cmd = "$# c -o:$# -d:release -d:case_testfile $#" % [nim, output, @@ -71,14 +71,10 @@ else: runTest("exitnow_139", 139) runTest("c_exit2_139", 139) runTest("quit_139", 139) - runTest("exit_array", 1) - when defined(posix): # on windows, -1073741571 - runTest("exit_recursion", SIGSEGV.int + 128) # bug #10273: was returning 0 - assertEquals exitStatusLikeShell(SIGSEGV), SIGSEGV + 128.cint block execProcessTest: let dir = parentDir(currentSourcePath()) - let (outp, err) = execCmdEx("nim c " & quoteShell(dir / "osproctest.nim")) + let (outp, err) = execCmdEx(nim & " c " & quoteShell(dir / "osproctest.nim")) doAssert err == 0 let exePath = dir / addFileExt("osproctest", ExeExt) let outStr1 = execProcess(exePath, workingDir = dir, args = ["foo", diff --git a/tests/system/t7894.nim b/tests/system/t7894.nim index b7ca1eec89..36711501e4 100644 --- a/tests/system/t7894.nim +++ b/tests/system/t7894.nim @@ -2,6 +2,7 @@ discard """ disabled: "travis" disabled: "appveyor" joinable: false +disabled: 32bit """ # CI integration servers are out of memory for this test diff --git a/tests/system/talloc2.nim b/tests/system/talloc2.nim index 7e0dec9d36..4958cda6dc 100644 --- a/tests/system/talloc2.nim +++ b/tests/system/talloc2.nim @@ -5,40 +5,42 @@ joinable: false # appveyor is "out of memory" -const - nmax = 2*1024*1024*1024 +when sizeof(int) >= 8: + # no point to test this on system with smaller address space + const + nmax = 2*1024*1024*1024 -proc test(n: int) = - var a = alloc0(9999) - var t = cast[ptr UncheckedArray[int8]](alloc(n)) - var b = alloc0(9999) - t[0] = 1 - t[1] = 2 - t[n-2] = 3 - t[n-1] = 4 - dealloc(a) - dealloc(t) - dealloc(b) + proc test(n: int) = + var a = alloc0(9999) + var t = cast[ptr UncheckedArray[int8]](alloc(n)) + var b = alloc0(9999) + t[0] = 1 + t[1] = 2 + t[n-2] = 3 + t[n-1] = 4 + dealloc(a) + dealloc(t) + dealloc(b) -# allocator adds 48 bytes to BigChunk -# BigChunk allocator edges at 2^n * (1 - s) for s = [1..32]/64 -proc test2(n: int) = - let d = n div 256 # cover edges and more - for i in countdown(128,1): - for j in [-4096, -64, -49, -48, -47, -32, 0, 4096]: - let b = n + j - i*d - if b>0 and b<=nmax: - test(b) - #echo b, ": ", getTotalMem(), " ", getOccupiedMem(), " ", getFreeMem() + # allocator adds 48 bytes to BigChunk + # BigChunk allocator edges at 2^n * (1 - s) for s = [1..32]/64 + proc test2(n: int) = + let d = n div 256 # cover edges and more + for i in countdown(128,1): + for j in [-4096, -64, -49, -48, -47, -32, 0, 4096]: + let b = n + j - i*d + if b>0 and b<=nmax: + test(b) + #echo b, ": ", getTotalMem(), " ", getOccupiedMem(), " ", getFreeMem() -proc test3 = - var n = 1 - while n <= nmax: - test2(n) - n *= 2 - n = nmax - while n >= 1: - test2(n) - n = n div 2 + proc test3 = + var n = 1 + while n <= nmax: + test2(n) + n *= 2 + n = nmax + while n >= 1: + test2(n) + n = n div 2 -test3() + test3() diff --git a/tests/types/tfinalobj.nim b/tests/types/tfinalobj.nim index 6a1c8c2ce7..94f2e4f0ec 100644 --- a/tests/types/tfinalobj.nim +++ b/tests/types/tfinalobj.nim @@ -1,6 +1,5 @@ discard """ - output: '''abc -16 == 16''' + output: '''abc''' """ type @@ -14,20 +13,3 @@ a.x = "abc" doAssert TA.sizeof == string.sizeof echo a.x - -########################################## -# bug #9794 -########################################## -type - imported_double {.importc: "double".} = object - - Pod = object - v* : imported_double - seed*: int32 - - Pod2 = tuple[v: imported_double, seed: int32] - -proc test() = - echo sizeof(Pod), " == ",sizeof(Pod2) - -test() \ No newline at end of file diff --git a/tests/vm/tvmops.nim b/tests/vm/tvmops.nim index c9caaf32b2..6442c49d6f 100644 --- a/tests/vm/tvmops.nim +++ b/tests/vm/tvmops.nim @@ -40,6 +40,11 @@ static: let a2 = arcsin 0.3 doAssert a1 == a2 + block bitxor: + let x = -1'i32 + let y = 1'i32 + doAssert (x xor y) == -2 + block: # Check against bugs like #9176 doAssert getCurrentCompilerExe() == forceConst(getCurrentCompilerExe()) diff --git a/tests/vm/tzero_extend.nim b/tests/vm/tzero_extend.nim index a79105531d..76aa9ee67b 100644 --- a/tests/vm/tzero_extend.nim +++ b/tests/vm/tzero_extend.nim @@ -13,14 +13,14 @@ proc get_values(): (seq[int8], seq[int16], seq[int32]) = result[0] = @[]; result[1] = @[]; result[2] = @[] for offset in RANGE: - let i8 = -(1 shl 9) + offset - let i16 = -(1 shl 17) + offset - let i32 = -(1 shl 33) + offset + let i8 = -(1'i64 shl 9) + offset + let i16 = -(1'i64 shl 17) + offset + let i32 = -(1'i64 shl 33) + offset # higher bits are masked. these should be exactly equal to offset. - result[0].add i8.toU8 - result[1].add i16.toU16 - result[2].add i32.toU32 + result[0].add cast[int8 ](uint8 cast[uint64](i8 )) + result[1].add cast[int16](uint16 cast[uint64](i16)) + result[2].add cast[int32](uint32 cast[uint64](i32)) # these values this computed by VM From b6c22eae6a73438ca9bf48281090ce0958475e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20D=C3=B6ring?= Date: Wed, 13 Feb 2019 08:04:06 +0100 Subject: [PATCH 36/50] disable talloc2 on 32 bits (#10656) --- tests/system/talloc2.nim | 71 ++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/tests/system/talloc2.nim b/tests/system/talloc2.nim index 4958cda6dc..a321fe741e 100644 --- a/tests/system/talloc2.nim +++ b/tests/system/talloc2.nim @@ -1,46 +1,45 @@ discard """ disabled: "windows" joinable: false +disabled: 32bit """ - +# no point to test this on system with smaller address space # appveyor is "out of memory" -when sizeof(int) >= 8: - # no point to test this on system with smaller address space - const - nmax = 2*1024*1024*1024 +const + nmax = 2*1024*1024*1024 - proc test(n: int) = - var a = alloc0(9999) - var t = cast[ptr UncheckedArray[int8]](alloc(n)) - var b = alloc0(9999) - t[0] = 1 - t[1] = 2 - t[n-2] = 3 - t[n-1] = 4 - dealloc(a) - dealloc(t) - dealloc(b) +proc test(n: int) = + var a = alloc0(9999) + var t = cast[ptr UncheckedArray[int8]](alloc(n)) + var b = alloc0(9999) + t[0] = 1 + t[1] = 2 + t[n-2] = 3 + t[n-1] = 4 + dealloc(a) + dealloc(t) + dealloc(b) - # allocator adds 48 bytes to BigChunk - # BigChunk allocator edges at 2^n * (1 - s) for s = [1..32]/64 - proc test2(n: int) = - let d = n div 256 # cover edges and more - for i in countdown(128,1): - for j in [-4096, -64, -49, -48, -47, -32, 0, 4096]: - let b = n + j - i*d - if b>0 and b<=nmax: - test(b) - #echo b, ": ", getTotalMem(), " ", getOccupiedMem(), " ", getFreeMem() +# allocator adds 48 bytes to BigChunk +# BigChunk allocator edges at 2^n * (1 - s) for s = [1..32]/64 +proc test2(n: int) = + let d = n div 256 # cover edges and more + for i in countdown(128,1): + for j in [-4096, -64, -49, -48, -47, -32, 0, 4096]: + let b = n + j - i*d + if b>0 and b<=nmax: + test(b) + #echo b, ": ", getTotalMem(), " ", getOccupiedMem(), " ", getFreeMem() - proc test3 = - var n = 1 - while n <= nmax: - test2(n) - n *= 2 - n = nmax - while n >= 1: - test2(n) - n = n div 2 +proc test3 = + var n = 1 + while n <= nmax: + test2(n) + n *= 2 + n = nmax + while n >= 1: + test2(n) + n = n div 2 - test3() +test3() From 3520253a09cb8f32df834e619c7435092a370e9d Mon Sep 17 00:00:00 2001 From: alaviss Date: Wed, 13 Feb 2019 14:07:58 +0700 Subject: [PATCH 37/50] compiler/types: correctly generates signature for non-proc types (#10658) This makes signatures generated for nimsuggest correctly distinguish template/macro/converter from proc. --- compiler/types.nim | 10 +++++++++- nimsuggest/tests/tsug_template.nim | 12 ++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 nimsuggest/tests/tsug_template.nim diff --git a/compiler/types.nim b/compiler/types.nim index 23902459e4..7034917d41 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -588,7 +588,15 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string = if prefer != preferExported: result.add("(" & typeToString(t.sons[0]) & ")") of tyProc: - result = if tfIterator in t.flags: "iterator " else: "proc " + result = if tfIterator in t.flags: "iterator " + elif t.owner != nil: + case t.owner.kind + of skTemplate: "template " + of skMacro: "macro " + of skConverter: "converter " + else: "proc " + else: + "proc " if tfUnresolved in t.flags: result.add "[*missing parameters*]" result.add "(" for i in countup(1, sonsLen(t) - 1): diff --git a/nimsuggest/tests/tsug_template.nim b/nimsuggest/tests/tsug_template.nim new file mode 100644 index 0000000000..3fa69322fe --- /dev/null +++ b/nimsuggest/tests/tsug_template.nim @@ -0,0 +1,12 @@ +template tmpa() = discard +macro tmpb() = discard +converter tmpc() = discard +tmp#[!]# + +discard """ +$nimsuggest --tester $file +>sug $1 +sug;;skMacro;;tsug_template.tmpb;;macro (){.noSideEffect, gcsafe, locks: 0.};;$file;;2;;6;;"";;0;;Prefix +sug;;skConverter;;tsug_template.tmpc;;converter ();;$file;;3;;10;;"";;0;;Prefix +sug;;skTemplate;;tsug_template.tmpa;;template (): typed;;$file;;1;;9;;"";;0;;Prefix +""" From 9913cef872cc2bcf8fe1567c5ed420c67859234c Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Thu, 14 Feb 2019 00:52:15 -0800 Subject: [PATCH 38/50] fix typo in codeReordering error msg (#10667) * fix typo in codeReordering * reorder=>codeReordering --- compiler/pragmas.nim | 2 +- compiler/reorder.nim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index d12f5f5d1a..f88035a077 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -241,7 +241,7 @@ proc pragmaNoForward(c: PContext, n: PNode; flag=sfNoForward) = # deprecated as of 0.18.1 message(c.config, n.info, warnDeprecated, - "use {.experimental: \"codeReordering.\".} instead; " & + "use {.experimental: \"codeReordering\".} instead; " & (if flag == sfNoForward: "{.noForward.}" else: "{.reorder.}") & " is deprecated") proc processCallConv(c: PContext, n: PNode) = diff --git a/compiler/reorder.nim b/compiler/reorder.nim index 8c4d0d307e..18ec659baf 100644 --- a/compiler/reorder.nim +++ b/compiler/reorder.nim @@ -212,7 +212,7 @@ proc mergeSections(conf: ConfigRef; comps: seq[seq[DepN]], res: PNode) = # Problematic circular dependency, we arrange the nodes into # their original relative order and make sure to re-merge # consecutive type and const sections - var wmsg = "Circular dependency detected. reorder pragma may not be able to" & + var wmsg = "Circular dependency detected. `codeReordering` pragma may not be able to" & " reorder some nodes properely" when defined(debugReorder): wmsg &= ":\n" From d2b3046c7073bc3316127258212a5fb140de8f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20D=C3=B6ring?= Date: Thu, 14 Feb 2019 10:58:09 +0100 Subject: [PATCH 39/50] deprecated leftovers from era of no unsigned integer types (#10605) --- lib/system.nim | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index ca4ac33cb3..af4214e9db 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -904,37 +904,51 @@ proc chr*(u: range[0..255]): char {.magic: "Chr", noSideEffect.} # built-in operators when not defined(JS): - proc ze*(x: int8): int {.magic: "Ze8ToI", noSideEffect.} + proc ze*(x: int8): int {.magic: "Ze8ToI", noSideEffect, deprecated.} ## zero extends a smaller integer type to ``int``. This treats `x` as ## unsigned. - proc ze*(x: int16): int {.magic: "Ze16ToI", noSideEffect.} + ## **Deprecated since version 0.19.9**: Use unsigned integers instead. + + proc ze*(x: int16): int {.magic: "Ze16ToI", noSideEffect, deprecated.} ## zero extends a smaller integer type to ``int``. This treats `x` as ## unsigned. + ## **Deprecated since version 0.19.9**: Use unsigned integers instead. - proc ze64*(x: int8): int64 {.magic: "Ze8ToI64", noSideEffect.} - ## zero extends a smaller integer type to ``int64``. This treats `x` as - ## unsigned. - proc ze64*(x: int16): int64 {.magic: "Ze16ToI64", noSideEffect.} + proc ze64*(x: int8): int64 {.magic: "Ze8ToI64", noSideEffect, deprecated.} ## zero extends a smaller integer type to ``int64``. This treats `x` as ## unsigned. + ## **Deprecated since version 0.19.9**: Use unsigned integers instead. - proc ze64*(x: int32): int64 {.magic: "Ze32ToI64", noSideEffect.} + proc ze64*(x: int16): int64 {.magic: "Ze16ToI64", noSideEffect, deprecated.} ## zero extends a smaller integer type to ``int64``. This treats `x` as ## unsigned. - proc ze64*(x: int): int64 {.magic: "ZeIToI64", noSideEffect.} + ## **Deprecated since version 0.19.9**: Use unsigned integers instead. + + proc ze64*(x: int32): int64 {.magic: "Ze32ToI64", noSideEffect, deprecated.} + ## zero extends a smaller integer type to ``int64``. This treats `x` as + ## unsigned. + ## **Deprecated since version 0.19.9**: Use unsigned integers instead. + + proc ze64*(x: int): int64 {.magic: "ZeIToI64", noSideEffect, deprecated.} ## zero extends a smaller integer type to ``int64``. This treats `x` as ## unsigned. Does nothing if the size of an ``int`` is the same as ``int64``. ## (This is the case on 64 bit processors.) + ## **Deprecated since version 0.19.9**: Use unsigned integers instead. - proc toU8*(x: int): int8 {.magic: "ToU8", noSideEffect.} + proc toU8*(x: int): int8 {.magic: "ToU8", noSideEffect, deprecated.} ## treats `x` as unsigned and converts it to a byte by taking the last 8 bits ## from `x`. - proc toU16*(x: int): int16 {.magic: "ToU16", noSideEffect.} + ## **Deprecated since version 0.19.9**: Use unsigned integers instead. + + proc toU16*(x: int): int16 {.magic: "ToU16", noSideEffect, deprecated.} ## treats `x` as unsigned and converts it to an ``int16`` by taking the last ## 16 bits from `x`. - proc toU32*(x: int64): int32 {.magic: "ToU32", noSideEffect.} + ## **Deprecated since version 0.19.9**: Use unsigned integers instead. + + proc toU32*(x: int64): int32 {.magic: "ToU32", noSideEffect, deprecated.} ## treats `x` as unsigned and converts it to an ``int32`` by taking the ## last 32 bits from `x`. + ## **Deprecated since version 0.19.9**: Use unsigned integers instead. # integer calculations: proc `+`*(x: int): int {.magic: "UnaryPlusI", noSideEffect.} From 70f0aab18835bbac748d8b95f5a93f7544380e3f Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 14 Feb 2019 11:04:43 +0100 Subject: [PATCH 40/50] osproc: fix minor typo --- lib/pure/osproc.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 78f9a06eb3..9502b679a7 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -224,7 +224,7 @@ proc execProcesses*(cmds: openArray[string], beforeRunEvent: proc(idx: int) = nil, afterRunEvent: proc(idx: int, p: Process) = nil): int {.rtl, extern: "nosp$1", - tags: [ExecIOEffect, TimeEffect, ReadEnvEffect, RootEffect]} = + tags: [ExecIOEffect, TimeEffect, ReadEnvEffect, RootEffect].} = ## executes the commands `cmds` in parallel. Creates `n` processes ## that execute in parallel. The highest (absolute) return value of all processes ## is returned. Runs `beforeRunEvent` before running each command. From b081eb4d6dbc541babce649af561e93e03420706 Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 14 Feb 2019 15:55:26 +0100 Subject: [PATCH 41/50] fixes #10651 --- compiler/jsgen.nim | 7 +++---- tests/js/tbasicenum.nim | 10 ---------- tests/js/tbasics.nim | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 14 deletions(-) delete mode 100644 tests/js/tbasicenum.nim create mode 100644 tests/js/tbasics.nim diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 8625f2fe1d..65706cdfaf 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -1149,7 +1149,7 @@ template isIndirect(x: PSym): bool = let v = x ({sfAddrTaken, sfGlobal} * v.flags != {} and #(mapType(v.typ) != etyObject) and - {sfImportc, sfVolatile, sfExportc} * v.flags == {} and + {sfImportc, sfExportc} * v.flags == {} and v.kind notin {skProc, skFunc, skConverter, skMethod, skIterator, skConst, skTemp, skLet}) @@ -1235,7 +1235,7 @@ proc genProcForSymIfNeeded(p: PProc, s: PSym) = proc genCopyForParamIfNeeded(p: PProc, n: PNode) = let s = n.sym - if p.prc == s.owner or needsNoCopy(p, n): + if p.prc == s.owner or needsNoCopy(p, n): return var owner = p.up while true: @@ -1597,8 +1597,7 @@ proc createVar(p: PProc, typ: PType, indirect: bool): Rope = internalError(p.config, "createVar: " & $t.kind) result = nil -template returnType: untyped = - ~"" +template returnType: untyped = ~"" proc genVarInit(p: PProc, v: PSym, n: PNode) = var diff --git a/tests/js/tbasicenum.nim b/tests/js/tbasicenum.nim deleted file mode 100644 index a9e9ce2dac..0000000000 --- a/tests/js/tbasicenum.nim +++ /dev/null @@ -1,10 +0,0 @@ -discard """ - output: "ABCDC" -""" - -type - MyEnum = enum - A,B,C,D -# trick the optimizer with an seq: -var x = @[A,B,C,D] -echo x[0],x[1],x[2],x[3],MyEnum(2) \ No newline at end of file diff --git a/tests/js/tbasics.nim b/tests/js/tbasics.nim new file mode 100644 index 0000000000..0c8d33e7fd --- /dev/null +++ b/tests/js/tbasics.nim @@ -0,0 +1,37 @@ +discard """ + output: '''ABCDC +1 +14 +ok''' +""" + +type + MyEnum = enum + A,B,C,D +# trick the optimizer with an seq: +var x = @[A,B,C,D] +echo x[0],x[1],x[2],x[3],MyEnum(2) + +# bug #10651 + +var xa: seq[int] +var ya = @[1,2] +xa &= ya +echo xa[0] + +proc test = + var yup: seq[int] + try: + yup.add 14 + echo yup.pop + finally: + discard + +test() + +when true: + var a: seq[int] + + a.setLen(0) + + echo "ok" \ No newline at end of file From 80992c7a1258d6ae0e0f322f3be0a1b955a96774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20D=C3=B6ring?= Date: Thu, 14 Feb 2019 22:17:05 +0100 Subject: [PATCH 42/50] introduce object before tuple in the tutorials (#10664) --- doc/tut1.rst | 116 ++++++++++++++++++++++++++++++++++++++++++--------- doc/tut2.rst | 25 ++++------- 2 files changed, 106 insertions(+), 35 deletions(-) diff --git a/doc/tut1.rst b/doc/tut1.rst index a7f1b741ad..161b4b904c 100644 --- a/doc/tut1.rst +++ b/doc/tut1.rst @@ -1441,31 +1441,111 @@ string that is "useless" and replace it with "useful". Note: alternate ways of writing this are ``b[^8..^2] = "useful"`` or as ``b[11..b.len-2] = "useful"`` or as ``b[11.. Error: type mismatch: got (tuple[street: string, number: int]) # but expected 'Person' - # The following works because the field names and types are the same. - var teacher: tuple[name: string, age: int] = ("Mark", 42) - person = teacher - Even though you don't need to declare a type for a tuple to use it, tuples created with different field names will be considered different objects despite having the same field types. @@ -1519,6 +1595,8 @@ variables! For example: echo badname echo badext +Fields of tuples are always public, they don't need to be explicity +marked to be exported, unlike for example fields in an object type. Reference and pointer types --------------------------- diff --git a/doc/tut2.rst b/doc/tut2.rst index d0c6e72479..4c1ec57476 100644 --- a/doc/tut2.rst +++ b/doc/tut2.rst @@ -40,18 +40,16 @@ and more efficient code. In particular, preferring composition over inheritance is often the better design. -Objects -------- +Inheritance +----------- -Like tuples, objects are a means to pack different values together in a -structured way. However, objects provide many features that tuples do not: -They provide inheritance and information hiding. Because objects encapsulate -data, the ``T()`` object constructor should only be used internally and the -programmer should provide a proc to initialize the object (this is called -a *constructor*). - -Objects have access to their type at runtime. There is an -``of`` operator that can be used to check the object's type: +Inheritance in Nim is entirely optional. To enable inheritance with +runtime type information the object needs to inherit from +``RootObj``. This can be done directly, or indirectly by +inheriting from an object that inherits from ``RootObj``. Usually +types with inheritance are also marked as ``ref`` types even though +this isn't strictly enforced. To check at runtime if an object is of a certain +type, the ``of`` operator can be used. .. code-block:: nim :test: "nim c $1" @@ -71,11 +69,6 @@ Objects have access to their type at runtime. There is an student = Student(name: "Anton", age: 5, id: 2) echo student[] -Object fields that should be visible from outside the defining module have to -be marked by ``*``. In contrast to tuples, different object types are -never *equivalent*. New object types can only be defined within a type -section. - Inheritance is done with the ``object of`` syntax. Multiple inheritance is currently not supported. If an object type has no suitable ancestor, ``RootObj`` can be used as its ancestor, but this is only a convention. Objects that have From 6d8ce609d7a5c2b24a2dc86db85a798436223ee6 Mon Sep 17 00:00:00 2001 From: Miran Date: Fri, 15 Feb 2019 08:41:43 +0100 Subject: [PATCH 43/50] add more nimble packages for testing (#10671) --- appveyor.yml | 4 +++ testament/categories.nim | 60 ++++++++++++++++++++------------ testament/important_packages.nim | 60 ++++++++++++++++++++------------ 3 files changed, 80 insertions(+), 44 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 9633bd15a5..4b5705fe21 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,6 +9,8 @@ environment: MINGW_DIR: mingw64 MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z/download MINGW_ARCHIVE: x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z + OPENBLAS_URL: https://sourceforge.net/projects/openblas/files/v0.3.5/OpenBLAS%200.3.5%20version.zip/download + OPENBLAS_ARCHIVE: OpenBLAS-0.3.5.zip SQLITE_URL: http://www.sqlite.org/2017/sqlite-dll-win64-x64-3160200.zip SQLITE_ARCHIVE: sqlite-dll-win64-x64-3160200.zip platform: x64 @@ -31,6 +33,8 @@ install: - 7z x -y "%SQLITE_ARCHIVE%" -o"%CD%\DIST"> nul - IF not exist "%MINGW_ARCHIVE%" appveyor DownloadFile "%MINGW_URL%" -FileName "%MINGW_ARCHIVE%" - 7z x -y "%MINGW_ARCHIVE%" -o"%CD%\DIST"> nul + - IF not exist "%OPENBLAS_ARCHIVE%" appveyor DownloadFile "%OPENBLAS_URL%" -FileName "%OPENBLAS_ARCHIVE%" + - 7z x -y "%OPENBLAS_ARCHIVE%" -o"%CD%\DIST"> nul - SET PATH=%CD%\DIST\%MINGW_DIR%\BIN;%CD%\BIN;%PATH% - IF "%PLATFORM%" == "x64" ( copy C:\OpenSSL-Win64\libeay32.dll %CD%\BIN\libeay64.dll & copy C:\OpenSSL-Win64\libeay32.dll %CD%\BIN\libeay32.dll & copy C:\OpenSSL-Win64\libssl32.dll %CD%\BIN\libssl64.dll & copy C:\OpenSSL-Win64\libssl32.dll %CD%\BIN\libssl32.dll ) ELSE ( copy C:\OpenSSL-Win32\libeay32.dll %CD%\BIN\libeay32.dll & copy C:\OpenSSL-Win32\libssl32.dll %CD%\BIN\libssl32.dll ) diff --git a/testament/categories.nim b/testament/categories.nim index 77769743dd..c7365e8fdf 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -471,7 +471,8 @@ proc getPackageDir(package: string): string = else: result = commandOutput[0].string -iterator listPackages(filter: PackageFilter): tuple[name, url, cmd: string] = +iterator listPackages(filter: PackageFilter): + tuple[name, url, cmd: string, hasDeps: bool] = const defaultCmd = "nimble test" let packageList = parseFile(packageIndex) for package in packageList.items: @@ -482,12 +483,12 @@ iterator listPackages(filter: PackageFilter): tuple[name, url, cmd: string] = case filter of pfCoreOnly: if "nim-lang" in normalize(url): - yield (name, url, defaultCmd) + yield (name, url, defaultCmd, false) of pfExtraOnly: - for n, cmd, commit in important_packages.packages.items: - if name == n: yield (name, url, cmd) + for n, cmd, commit, hasDeps in important_packages.packages.items: + if name == n: yield (name, url, cmd, hasDeps) of pfAll: - yield (name, url, defaultCmd) + yield (name, url, defaultCmd, false) proc makeSupTest(test, options: string, cat: Category): TTest = result.cat = cat @@ -506,32 +507,47 @@ proc testNimblePackages(r: var TResults, cat: Category, filter: PackageFilter) = let packageFileTest = makeSupTest("PackageFileParsed", "", cat) var keepDir = false + var packagesDir = "pkgstemp" try: - for name, url, cmd in listPackages(filter): + for name, url, cmd, hasDep in listPackages(filter): var test = makeSupTest(url, "", cat) - let buildPath = "pkgstemp" / name - let installProcess = startProcess("git", "", ["clone", url, buildPath]) - let installStatus = waitForExitEx(installProcess) - installProcess.close - if installStatus != QuitSuccess: - r.addResult(test, targetC, "", "", reInstallFailed) + let buildPath = packagesDir / name + if not existsDir(buildPath): + if hasDep: + let nimbleProcess = startProcess("nimble", "", ["install", "-y", name], + options = {poUsePath, poStdErrToStdOut}) + let nimbleStatus = waitForExitEx(nimbleProcess) + nimbleProcess.close + if nimbleStatus != QuitSuccess: + r.addResult(test, targetC, "", "", reInstallFailed) + keepDir = true + continue + + let installProcess = startProcess("git", "", ["clone", url, buildPath], + options = {poUsePath, poStdErrToStdOut}) + let installStatus = waitForExitEx(installProcess) + installProcess.close + if installStatus != QuitSuccess: + r.addResult(test, targetC, "", "", reInstallFailed) + keepDir = true + continue + + let cmdArgs = parseCmdLine(cmd) + let buildProcess = startProcess(cmdArgs[0], buildPath, cmdArgs[1..^1], + options = {poUsePath, poStdErrToStdOut}) + let buildStatus = waitForExitEx(buildProcess) + buildProcess.close + if buildStatus != QuitSuccess: + r.addResult(test, targetC, "", "", reBuildFailed) keepDir = true else: - let cmdArgs = parseCmdLine(cmd) - let buildProcess = startProcess(cmdArgs[0], buildPath, cmdArgs[1..^1]) - let buildStatus = waitForExitEx(buildProcess) - buildProcess.close - if buildStatus != QuitSuccess: - r.addResult(test, targetC, "", "", reBuildFailed) - keepDir = true - else: - r.addResult(test, targetC, "", "", reSuccess) + r.addResult(test, targetC, "", "", reSuccess) r.addResult(packageFileTest, targetC, "", "", reSuccess) except JsonParsingError: echo("[Warning] - Cannot run nimble tests: Invalid package file.") r.addResult(packageFileTest, targetC, "", "", reBuildFailed) finally: - if not keepDir: removeDir("pkgstemp") + if not keepDir: removeDir(packagesDir) # ---------------------------------------------------------------------------- diff --git a/testament/important_packages.nim b/testament/important_packages.nim index fbb3edaa8b..e4cbec7f8b 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -1,28 +1,44 @@ import strutils -template pkg(name: string; cmd = "nimble test"; version = ""): untyped = - packages.add((name, cmd, version)) +template pkg(name: string; cmd = "nimble test"; version = ""; hasDeps = false): untyped = + packages.add((name, cmd, version, hasDeps)) -var packages*: seq[tuple[name, cmd, version: string]] = @[] +var packages*: seq[tuple[name, cmd, version: string; hasDeps: bool]] = @[] -pkg "karax" -pkg "cligen" -pkg "glob" -#pkg "regex" -pkg "freeimage", "nim c freeimage.nim" -pkg "zero_functional" -pkg "nimpy", "nim c nimpy.nim" -#pkg "nimongo", "nimble test_ci" -pkg "inim" -pkg "sdl1", "nim c src/sdl.nim" -pkg "iterutils" -pkg "gnuplot" +pkg "arraymancer", "nim c src/arraymancer.nim", "", true +pkg "ast_pattern_matching", "nim c tests/test1.nim" pkg "c2nim" - -#[ - arraymancer - nimpb - jester - nimx -]# +pkg "cligen", "nim c -o:cligenn cligen.nim" +pkg "compactdict", "nim c tests/test1.nim" +pkg "criterion" +pkg "docopt" +pkg "gara", "nim c tests/test_gara.nim" +pkg "glob" +pkg "gnuplot" +pkg "hts", "nim c tests/all.nim" +pkg "inim" +pkg "itertools", "nim doc src/itertools.nim" +pkg "iterutils" +pkg "karax", "nim c tests/tester.nim" +pkg "loopfusion" +pkg "nake", "nim c nakefile.nim" +pkg "neo", "nim c -d:blas=openblas tests/all.nim", "", true +pkg "nigui", "nim c -o:niguii src/nigui.nim" +pkg "NimData", "nim c -o:nimdataa src/nimdata.nim", "", true +pkg "nimes", "nim c src/nimes.nim", "", true +pkg "nimgame2", "nim c nimgame2/nimgame.nim", "", true +pkg "nimongo", "nimble test_ci", "", true +pkg "nimpy", "nim c -o:nimpyy nimpy.nim" +pkg "nimsl", "nim c test.nim" +pkg "nimx", "nim c --threads:on test/main.nim", "", true +pkg "parsetoml" +pkg "patty" +pkg "plotly", "nim c examples/all.nim", "", true +pkg "protobuf", "nim c -o:protobuff src/protobuf.nim", "", true +pkg "regex", "nim c src/regex" +pkg "rosencrantz", "nim c -o:rsncntz rosencrantz.nim" +pkg "sdl1", "nim c src/sdl.nim" +pkg "sdl2_nim", "nim c sdl2/sdl.nim" +pkg "stint", "nim c -o:stintt stint.nim" +pkg "zero_functional", "nim c test.nim" From b3ffbac93c1485ca9b7fd5f5d7ddd3fb9461d8e4 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Fri, 15 Feb 2019 04:42:13 -0300 Subject: [PATCH 44/50] Return result when found instead of keep iterating for no reason the whole mimedb on mimetypes module (#10675) --- lib/pure/mimetypes.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pure/mimetypes.nim b/lib/pure/mimetypes.nim index 57ea825270..97ebd35c2b 100644 --- a/lib/pure/mimetypes.nim +++ b/lib/pure/mimetypes.nim @@ -1906,6 +1906,7 @@ func getExt*(mimedb: MimeDB, mimetype: string, default = "txt"): string = for e, m in mimedb.mimes: if m == mimeLowered: result = e + break func register*(mimedb: var MimeDB, ext: string, mimetype: string) = ## Adds ``mimetype`` to the ``mimedb``. From 1eaa18fe84a135d246baf9eb7125c2c540e27603 Mon Sep 17 00:00:00 2001 From: narimiran Date: Fri, 15 Feb 2019 11:09:32 +0100 Subject: [PATCH 45/50] allow string insert in nimscript, fixes #10561 --- lib/system.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/system.nim b/lib/system.nim index af4214e9db..d92848d40c 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3873,7 +3873,7 @@ when false: macro payload: typed {.gensym.} = blk payload() -when hasAlloc: +when hasAlloc or defined(nimscript): proc insert*(x: var string, item: string, i = 0.Natural) {.noSideEffect.} = ## inserts `item` into `x` at position `i`. var xl = x.len From 2610b16f6ede15888de9769b7226233dc8e86b68 Mon Sep 17 00:00:00 2001 From: liuxiaodong Date: Sat, 16 Feb 2019 00:43:22 +0800 Subject: [PATCH 46/50] some dom proc correction and complement (#10684) --- lib/js/dom.nim | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/js/dom.nim b/lib/js/dom.nim index 9d6cd91525..3c6d65d8a1 100644 --- a/lib/js/dom.nim +++ b/lib/js/dom.nim @@ -192,7 +192,7 @@ type Element* = ref ElementObj ElementObj {.importc.} = object of NodeObj - classList*: Classlist + classList*: ClassList checked*: bool defaultChecked*: bool defaultValue*: cstring @@ -1183,9 +1183,10 @@ proc contains*(c: ClassList, class: cstring): bool proc toggle*(c: ClassList, class: cstring) # Style "methods" -proc getAttribute*(s: Style, attr: cstring, caseSensitive=false): cstring -proc removeAttribute*(s: Style, attr: cstring, caseSensitive=false) -proc setAttribute*(s: Style, attr, value: cstring, caseSensitive=false) +proc getPropertyValue*(s: Style, property: cstring): cstring +proc removeProperty*(s: Style, property: cstring) +proc setProperty*(s: Style, property, value: cstring, priority = "") +proc getPropertyPriority*(s: Style, property: cstring): cstring # Event "methods" proc preventDefault*(ev: Event) @@ -1267,6 +1268,10 @@ proc inViewport*(el: Node): bool = rect.right <= clientWidth().float proc scrollTop*(e: Node): int {.importcpp: "#.scrollTop", nodecl.} +proc scrollLeft*(e: Node): int {.importcpp: "#.scrollLeft", nodecl.} +proc scrollHeight*(e: Node): int {.importcpp: "#.scrollHeight", nodecl.} +proc scrollWidth*(e: Node): int {.importcpp: "#.scrollWidth", nodecl.} proc offsetHeight*(e: Node): int {.importcpp: "#.offsetHeight", nodecl.} +proc offsetWidth*(e: Node): int {.importcpp: "#.offsetWidth", nodecl.} proc offsetTop*(e: Node): int {.importcpp: "#.offsetTop", nodecl.} proc offsetLeft*(e: Node): int {.importcpp: "#.offsetLeft", nodecl.} From 51c43218c954a884da8056e0a35cfb6bcfcd214b Mon Sep 17 00:00:00 2001 From: Federico Ceratto Date: Sat, 16 Feb 2019 14:56:26 +0000 Subject: [PATCH 47/50] Comment on isSorted complexity. (#10686) [ci skip] --- lib/pure/algorithm.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/algorithm.nim b/lib/pure/algorithm.nim index 8c8838ed2e..b346c7a448 100644 --- a/lib/pure/algorithm.nim +++ b/lib/pure/algorithm.nim @@ -511,7 +511,7 @@ func isSorted*[T](a: openArray[T], order = SortOrder.Ascending): bool = ## Checks to see whether ``a`` is already sorted in ``order`` ## using ``cmp`` for the comparison. Parameters identical - ## to ``sort``. + ## to ``sort``. Requires O(n) time. ## ## **See also:** ## * `isSorted proc<#isSorted,openArray[T]>`_ From a0fb77dfd5305b552b45fbe2f0a8c38ee8133b3a Mon Sep 17 00:00:00 2001 From: narimiran Date: Sat, 16 Feb 2019 17:06:09 +0100 Subject: [PATCH 48/50] add links to every document, fixes #5515 --- config/nimdoc.cfg | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/config/nimdoc.cfg b/config/nimdoc.cfg index cd29cbae0f..c5effd04e7 100644 --- a/config/nimdoc.cfg +++ b/config/nimdoc.cfg @@ -77,7 +77,20 @@ $content doc.body_toc = """
-
+ +
Search:
From d8ff25f03250556c3ed99dbb7ad65d1cc627e1d3 Mon Sep 17 00:00:00 2001 From: Federico Ceratto Date: Wed, 13 Feb 2019 19:57:25 +0000 Subject: [PATCH 49/50] Provide access to getsockname()/getpeername() Port of #3323 with added tests --- lib/pure/asyncnet.nim | 12 ++++++++++++ tests/async/tasyncawait.nim | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim index 1c0681fada..56bda737a6 100644 --- a/lib/pure/asyncnet.nim +++ b/lib/pure/asyncnet.nim @@ -166,6 +166,18 @@ proc newAsyncSocket*(domain: Domain = AF_INET, sockType: SockType = SOCK_STREAM, raiseOSError(osLastError()) result = newAsyncSocket(fd, domain, sockType, protocol, buffered) +proc getLocalAddr*(socket: AsyncSocket): (string, Port) = + ## Get the socket's local address and port number. + ## + ## This is high-level interface for `getsockname`:idx:. + getLocalAddr(socket.fd, socket.domain) + +proc getPeerAddr*(socket: AsyncSocket): (string, Port) = + ## Get the socket's peer address and port number. + ## + ## This is high-level interface for `getpeername`:idx:. + getPeerAddr(socket.fd, socket.domain) + proc newAsyncSocket*(domain, sockType, protocol: cint, buffered = true): AsyncSocket = ## Creates a new asynchronous socket. diff --git a/tests/async/tasyncawait.nim b/tests/async/tasyncawait.nim index 1e6cf3761a..063c8317cc 100644 --- a/tests/async/tasyncawait.nim +++ b/tests/async/tasyncawait.nim @@ -26,6 +26,10 @@ proc launchSwarm(port: Port) {.async.} = proc readMessages(client: AsyncFD) {.async.} = # wrapping the AsyncFd into a AsyncSocket object var sockObj = newAsyncSocket(client) + var (ipaddr, port) = sockObj.getPeerAddr() + doAssert ipaddr == "127.0.0.1" + (ipaddr, port) = sockObj.getLocalAddr() + doAssert ipaddr == "127.0.0.1" while true: var line = await recvLine(sockObj) if line == "": From 8b39551fca81e95b51393a2a8e702eebe3ba7c51 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 18 Feb 2019 08:07:10 +0100 Subject: [PATCH 50/50] Small CI improvements (#10699) * [appveyor] Cache all the downloaded binaries * [travis] Enable fast_finish --- .travis.yml | 2 ++ appveyor.yml | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index c202a16546..279da7920a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ language: c dist: xenial matrix: + fast_finish: true + include: - os: linux env: NIM_COMPILE_TO_CPP=false diff --git a/appveyor.yml b/appveyor.yml index 4b5705fe21..31be04d1b4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,10 +1,5 @@ version: '{build}' -cache: -- x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z -- sqlite-dll-win64-x64-3160200.zip -# - i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z - environment: MINGW_DIR: mingw64 MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z/download @@ -19,6 +14,11 @@ environment: - NIM_TEST_PACKAGES: true - NIM_TEST_PACKAGES: false +cache: + - '%MINGW_ARCHIVE%' + - '%SQLITE_ARCHIVE%' + - '%OPENBLAS_ARCHIVE%' + matrix: #allow_failures: # - NIM_TEST_PACKAGES: true