diff options
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | compiler/ccgtypes.nim | 54 | ||||
-rw-r--r-- | compiler/nimfix/nimfix.nim.cfg | 2 | ||||
-rw-r--r-- | compiler/sempass2.nim | 2 | ||||
-rw-r--r-- | compiler/semstmts.nim | 2 | ||||
-rwxr-xr-x | tests/test_nimscript.nims | 25 | ||||
-rw-r--r-- | todo.txt | 5 | ||||
-rw-r--r-- | tools/heapdumprepl.nim | 150 | ||||
-rw-r--r-- | web/news/version_0_14_released.rst.todo | 120 |
9 files changed, 326 insertions, 35 deletions
diff --git a/.travis.yml b/.travis.yml index f68375e93..f8655f940 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,7 @@ script: - ./koch boot - ./koch boot -d:release - nim e install_nimble.nims + - nim e tests/test_nimscript.nims - nimble update - nimble install zip - nimble install opengl diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 0e4080c5d..4de196fe0 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -573,34 +573,34 @@ proc getTypeDescAux(m: BModule, typ: PType, check: var IntSet): Rope = result = getTypeDescWeak(m, t.sons[0], check) & "*" idTablePut(m.typeCache, t, result) of tyRange, tyEnum: - let orig = t let t = if t.kind == tyRange: t.lastSon else: t - result = getTypeName(t) - if not (isImportedCppType(t) or - (sfImportc in t.sym.flags and t.sym.magic == mNone)): - idTablePut(m.typeCache, t, result) - if t != orig: idTablePut(m.typeCache, orig, result) - var size: int - if firstOrd(t) < 0: - addf(m.s[cfsTypes], "typedef NI32 $1;$n", [result]) - size = 4 - else: - size = int(getSize(t)) - case size - of 1: addf(m.s[cfsTypes], "typedef NU8 $1;$n", [result]) - of 2: addf(m.s[cfsTypes], "typedef NU16 $1;$n", [result]) - of 4: addf(m.s[cfsTypes], "typedef NI32 $1;$n", [result]) - of 8: addf(m.s[cfsTypes], "typedef NI64 $1;$n", [result]) - else: internalError(t.sym.info, "getTypeDescAux: enum") - let owner = hashOwner(t.sym) - if not gDebugInfo.hasEnum(t.sym.name.s, t.sym.info.line, owner): - var vals: seq[(string, int)] = @[] - for i in countup(0, t.n.len - 1): - assert(t.n.sons[i].kind == nkSym) - let field = t.n.sons[i].sym - vals.add((field.name.s, field.position.int)) - gDebugInfo.registerEnum(EnumDesc(size: size, owner: owner, id: t.sym.id, - name: t.sym.name.s, values: vals)) + result = cacheGetType(m.typeCache, t) + if result == nil: + result = getTypeName(t) + if not (isImportedCppType(t) or + (sfImportc in t.sym.flags and t.sym.magic == mNone)): + idTablePut(m.typeCache, t, result) + var size: int + if firstOrd(t) < 0: + addf(m.s[cfsTypes], "typedef NI32 $1;$n", [result]) + size = 4 + else: + size = int(getSize(t)) + case size + of 1: addf(m.s[cfsTypes], "typedef NU8 $1;$n", [result]) + of 2: addf(m.s[cfsTypes], "typedef NU16 $1;$n", [result]) + of 4: addf(m.s[cfsTypes], "typedef NI32 $1;$n", [result]) + of 8: addf(m.s[cfsTypes], "typedef NI64 $1;$n", [result]) + else: internalError(t.sym.info, "getTypeDescAux: enum") + let owner = hashOwner(t.sym) + if not gDebugInfo.hasEnum(t.sym.name.s, t.sym.info.line, owner): + var vals: seq[(string, int)] = @[] + for i in countup(0, t.n.len - 1): + assert(t.n.sons[i].kind == nkSym) + let field = t.n.sons[i].sym + vals.add((field.name.s, field.position.int)) + gDebugInfo.registerEnum(EnumDesc(size: size, owner: owner, id: t.sym.id, + name: t.sym.name.s, values: vals)) of tyProc: result = getTypeName(t) idTablePut(m.typeCache, t, result) diff --git a/compiler/nimfix/nimfix.nim.cfg b/compiler/nimfix/nimfix.nim.cfg index 73219d6f8..0d9dbfa4b 100644 --- a/compiler/nimfix/nimfix.nim.cfg +++ b/compiler/nimfix/nimfix.nim.cfg @@ -5,7 +5,7 @@ hint[XDeclaredButNotUsed]:off path:"$projectPath/.." path:"$lib/packages/docutils" -path:"../../compiler" +path:"$nim" define:useStdoutAsStdmsg symbol:nimfix diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index c3a9e01a0..218ab2704 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -505,7 +505,7 @@ proc notNilCheck(tracked: PEffects, n: PNode, paramType: PType) = # addr(x[]) can't be proven, but addr(x) can: if not containsNode(n, {nkDerefExpr, nkHiddenDeref}): return elif (n.kind == nkSym and n.sym.kind in routineKinds) or - n.kind in procDefs+{nkObjConstr}: + n.kind in procDefs+{nkObjConstr, nkBracket}: # 'p' is not nil obviously: return case impliesNotNil(tracked.guards, n) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 0b2343c10..7155f9c7a 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -337,7 +337,7 @@ proc checkNilable(v: PSym) = {tfNotNil, tfNeedsInit} * v.typ.flags != {}: if v.ast.isNil: message(v.info, warnProveInit, v.name.s) - elif tfNotNil in v.typ.flags and tfNotNil notin v.ast.typ.flags: + elif tfNeedsInit in v.typ.flags and tfNotNil notin v.ast.typ.flags: message(v.info, warnProveInit, v.name.s) include semasgn diff --git a/tests/test_nimscript.nims b/tests/test_nimscript.nims new file mode 100755 index 000000000..436e990ef --- /dev/null +++ b/tests/test_nimscript.nims @@ -0,0 +1,25 @@ +# This nimscript is used to test if the following modules can be imported +# http://nim-lang.org/docs/nims.html + +import algorithm +import base64 +import colors +import hashes +import lists +import math +# import marshal +import options +import ospaths +# import parsecfg +# import parseopt +import parseutils +# import pegs +import queues +import sequtils +import strutils +import subexes +import tables +import unicode +import uri + +echo "Nimscript imports are successful." diff --git a/todo.txt b/todo.txt index 542f096fb..863811ddf 100644 --- a/todo.txt +++ b/todo.txt @@ -12,18 +12,17 @@ essential for 1.0 - overloading of `()` needs to be in .experimental - find a solution for the x.f[T](y) gotcha - ``concept`` needs to be refined, a nice name for the feature is not enough. -- Destructors need to be refined. - make '--implicitStatic:on' the default; then we can also clean up the 'static[T]' mess in the compiler! - - Deprecate ``immediate`` for templates and macros - document NimMain and check whether it works for threading -- ``not`` or ``~`` for the effects system Not critical for 1.0 ==================== +- Destructors need to be refined. +- ``not`` or ``~`` for the effects system - document and stress test ``.partial`` object declarations - add "all threads are blocked" detection to 'spawn' - figure out why C++ bootstrapping is so much slower diff --git a/tools/heapdumprepl.nim b/tools/heapdumprepl.nim new file mode 100644 index 000000000..ffa153f5d --- /dev/null +++ b/tools/heapdumprepl.nim @@ -0,0 +1,150 @@ + +include prelude +import intsets + +type + NodeKind = enum + internal, local, localInvalid, global, globalInvalid + Color = enum + white, grey, black + Node = ref object + id, rc: int + kids: seq[int] + k: NodeKind + col: Color + Graph = object + nodes: Table[int, Node] + roots: Table[int, NodeKind] + +proc add(father: Node; son: int) = + if father.kids.isNil: father.kids = @[] + father.kids.add(son) + +proc renderNode(g: Graph; id: int) = + let n = g.nodes[id] + echo n[] + +proc toNodeId(aliases: var Table[string,int]; s: string): int = + result = aliases.getOrDefault(s) + if result == 0: + if s.startsWith("x"): + discard s.parseHex(result, 1) + else: + result = s.parseInt + +proc parseHex(s: string): int = + discard parseutils.parseHex(s, result, 0) + +proc reachable(g: Graph; stack: var seq[int]; goal: int): bool = + var t = initIntSet() + while stack.len > 0: + let it = stack.pop + if not t.containsOrIncl(it): + if it == goal: return true + if it in g.nodes: + for kid in g.nodes[it].kids: + stack.add(kid) + +const Help = """ +quit -- quits this REPL +locals, l -- output the list of local stack roots +globals, g -- output the list of global roots +alias name addr -- give addr a name. start 'addr' with 'x' for hexidecimal + notation +print name|addr -- print a node by name or address +reachable,r l|g|node dest -- outputs TRUE or FALSE depending on whether + dest is reachable by (l)ocals, (g)lobals or by the + other given node. Nodes can be node names or node + addresses. +""" + +proc repl(g: Graph) = + var aliases = initTable[string,int]() + while true: + let line = stdin.readLine() + let data = line.split() + if data.len == 0: continue + case data[0] + of "quit": + break + of "help": + echo Help + of "locals", "l": + for k,v in g.roots: + if v == local: renderNode(g, k) + of "globals", "g": + for k,v in g.roots: + if v == global: renderNode(g, k) + of "alias", "a": + # generate alias + if data.len == 3: + aliases[data[1]] = toNodeId(aliases, data[2]) + of "print", "p": + if data.len == 2: + renderNode(g, toNodeId(aliases, data[1])) + of "reachable", "r": + if data.len == 3: + var stack: seq[int] = @[] + case data[1] + of "locals", "l": + for k,v in g.roots: + if v == local: stack.add k + of "globals", "g": + for k,v in g.roots: + if v == global: stack.add k + else: + stack.add(toNodeId(aliases, data[1])) + let goal = toNodeId(aliases, data[2]) + echo reachable(g, stack, goal) + else: discard + +proc importData(input: string): Graph = + #c_fprintf(file, "%s %p %d rc=%ld color=%c\n", + # msg, c, kind, c.refcount shr rcShift, col) + # cell 0x10a908190 22 rc=2 color=w + var i: File + var + nodes = initTable[int, Node]() + roots = initTable[int, NodeKind]() + if open(i, input): + var currNode: Node + for line in lines(i): + let data = line.split() + if data.len == 0: continue + case data[0] + of "end": + currNode = nil + of "cell": + let rc = parseInt(data[3].substr("rc=".len)) + let col = case data[4].substr("color=".len) + of "b": black + of "w": white + of "g": grey + else: (assert(false); grey) + let id = parseHex(data[1]) + currNode = Node(id: id, + k: roots.getOrDefault(id), + rc: rc, col: col) + nodes[currNode.id] = currNode + of "child": + assert currNode != nil + currNode.add parseHex(data[1]) + of "global_root": + roots[data[1].parseHex] = global + of "global_root_invalid": + roots[data[1].parseHex] = globalInvalid + of "onstack": + roots[data[1].parseHex] = local + of "onstack_invalid": + roots[data[1].parseHex] = localInvalid + else: discard + close(i) + else: + quit "error: cannot open " & input + shallowCopy(result.nodes, nodes) + shallowCopy(result.roots, roots) + +if paramCount() == 1: + repl(importData(paramStr(1))) +else: + quit "usage: heapdumprepl inputfile" diff --git a/web/news/version_0_14_released.rst.todo b/web/news/version_0_14_released.rst.todo index a31b952e6..7aa4e0359 100644 --- a/web/news/version_0_14_released.rst.todo +++ b/web/news/version_0_14_released.rst.todo @@ -97,8 +97,13 @@ Language Additions that arise when types are mutually dependent and yet should be kept in different modules. -Bug fixes ---------- +Bugfixes +-------- + +The list below has been generated based on the commits in Nim's git +repository. As such it lists only the issues which have been closed +via a commit, for a full list see +`this link on Github <https://github.com/nim-lang/Nim/issues?utf8=%E2%9C%93&q=is%3Aissue+closed%3A%222016-01-19+..+2016-06-06%22+>`_. - Fixed "Calling generic templates with explicit generic arguments crashes compiler" @@ -215,3 +220,114 @@ Bug fixes (`#4070 <https://github.com/nim-lang/Nim/issues/4070>`_) - Fixed "`$` For array crashes the compiler when assigned to const" (`#4040 <https://github.com/nim-lang/Nim/issues/4040>`_) + + - Fixed "Default value for .importcpp enum is initialized incorrectly" + (`#4034 <https://github.com/nim-lang/Nim/issues/4034>`_) + - Fixed "Nim doesn't instantiate template parameter in cgen when using procedure return value in for-in loop" + (`#4110 <https://github.com/nim-lang/Nim/issues/4110>`_) + - Fixed "Compile-time SIGSEGV when invoking procedures that cannot be evaluated at compile time from a macro" + (`#3956 <https://github.com/nim-lang/Nim/issues/3956>`_) + - Fixed "Backtricks inside .emit pragma output incorrect name for types" + (`#3992 <https://github.com/nim-lang/Nim/issues/3992>`_) + - Fixed "typedef is generated for .importcpp enums" + (`#4145 <https://github.com/nim-lang/Nim/issues/4145>`_) + - Fixed "Incorrect C code generated for nnkEmpty node" + (`#950 <https://github.com/nim-lang/Nim/issues/950>`_) + - Fixed "Syntax error in config file appears as general exception without useful info" + (`#3763 <https://github.com/nim-lang/Nim/issues/3763>`_) + - Fixed "Converting .importcpp enum to string doesn't work when done inside procs" + (`#4147 <https://github.com/nim-lang/Nim/issues/4147>`_) + - Fixed "Enum template specifiers do not work for .importcpp enums when they are used as a parameter" + (`#4146 <https://github.com/nim-lang/Nim/issues/4146>`_) + - Fixed "Providing template specifier recursively for .importcpp type doesn't work" + (`#4148 <https://github.com/nim-lang/Nim/issues/4148>`_) + - Fixed "sizeof doesn't work for generics in vm" + (`#4153 <https://github.com/nim-lang/Nim/issues/4153>`_) + - Fixed "Creating list-like structures in a loop leaks memory indefinitely" + (`#3793 <https://github.com/nim-lang/Nim/issues/3793>`_) + - Fixed "Creating list-like structures in a loop leaks memory indefinitely" + (`#3793 <https://github.com/nim-lang/Nim/issues/3793>`_) + - Fixed "Enum items generated by a macro have wrong type." + (`#4066 <https://github.com/nim-lang/Nim/issues/4066>`_) + - Fixed "Memory leak with default GC" + (`#3184 <https://github.com/nim-lang/Nim/issues/3184>`_) + - Fixed "Rationals Overflow Error on 32-bit machine" + (`#4194 <https://github.com/nim-lang/Nim/issues/4194>`_) + + - Fixed "osproc waitForExit() is ignoring the timeout parameter" + (`#4200 <https://github.com/nim-lang/Nim/issues/4200>`_) + - Fixed "Regression: exception parseFloat("-0.0") " + (`#4212 <https://github.com/nim-lang/Nim/issues/4212>`_) + - Fixed "JS Codegen: Bad constant initialization order" + (`#4222 <https://github.com/nim-lang/Nim/issues/4222>`_) + - Fixed "Term-rewriting macros gives Error: wrong number of arguments" + (`#4227 <https://github.com/nim-lang/Nim/issues/4227>`_) + - Fixed "importcpp allowed in body of proc after push" + (`#4225 <https://github.com/nim-lang/Nim/issues/4225>`_) + - Fixed "pragma SIGSEGV" + (`#4001 <https://github.com/nim-lang/Nim/issues/4001>`_) + - Fixed "Restrict hints to the current project" + (`#2159 <https://github.com/nim-lang/Nim/issues/2159>`_) + - Fixed "`unlikely`/`likely` should be no-ops for the Javascript backend" + (`#3882 <https://github.com/nim-lang/Nim/issues/3882>`_) + - Fixed ".this pragma doesn't work for fields and procs defined for parent type" + (`#4177 <https://github.com/nim-lang/Nim/issues/4177>`_) + - Fixed "VM SIGSEV with compile-time Table" + (`#3729 <https://github.com/nim-lang/Nim/issues/3729>`_) + - Fixed "Error during compilation with cpp option on FreeBSD " + (`#3059 <https://github.com/nim-lang/Nim/issues/3059>`_) + - Fixed "Compiler doesn't keep type bounds" + (`#1713 <https://github.com/nim-lang/Nim/issues/1713>`_) + - Fixed "Stdlib: future: Shortcut proc definition doesn't support, varargs, seqs, arrays, or openarrays" + (`#4238 <https://github.com/nim-lang/Nim/issues/4238>`_) + - Fixed "Why don't ``asynchttpserver`` support request-body when ``put`` ``delete``?" + (`#4221 <https://github.com/nim-lang/Nim/issues/4221>`_) + - Fixed "Paths for includes in Nim documentation" + (`#2640 <https://github.com/nim-lang/Nim/issues/2640>`_) + - Fixed "Compile pragma doesn't work with relative import" + (`#1262 <https://github.com/nim-lang/Nim/issues/1262>`_) + - Fixed "Slurp doesn't work with relative imports" + (`#765 <https://github.com/nim-lang/Nim/issues/765>`_) + - Fixed "Make tilde expansion consistent" + (`#786 <https://github.com/nim-lang/Nim/issues/786>`_) + - Fixed "koch expects nim to be in path for tests?" + (`#3290 <https://github.com/nim-lang/Nim/issues/3290>`_) + - Fixed "Don't use relative imports for non relative modules (aka babel libs)" + (`#546 <https://github.com/nim-lang/Nim/issues/546>`_) + - Fixed ""echo" on general structs does not work" + (`#4236 <https://github.com/nim-lang/Nim/issues/4236>`_) + - Fixed "Changing math.round() and adding math.integer()" + (`#3473 <https://github.com/nim-lang/Nim/issues/3473>`_) + - Fixed "Mathematics module missing modf" + (`#4195 <https://github.com/nim-lang/Nim/issues/4195>`_) + - Fixed "Passing method to macro causes seg fault" + (`#1611 <https://github.com/nim-lang/Nim/issues/1611>`_) + - Fixed "Internal error with "discard quit"" + (`#3532 <https://github.com/nim-lang/Nim/issues/3532>`_) + - Fixed "SIGSEGV when using object variant in compile time" + (`#4207 <https://github.com/nim-lang/Nim/issues/4207>`_) + - Fixed "formatSize has incorrect prefix" + (`#4198 <https://github.com/nim-lang/Nim/issues/4198>`_) + - Fixed "Add compiler parameter to generate output from source code filters" + (`#375 <https://github.com/nim-lang/Nim/issues/375>`_) + - Fixed "Add engineering notation to string formatting functions" + (`#4197 <https://github.com/nim-lang/Nim/issues/4197>`_) + - Fixed "Very minor error in json documentation" + (`#4255 <https://github.com/nim-lang/Nim/issues/4255>`_) + - Fixed "can't compile when checking if closure == nil" + (`#4186 <https://github.com/nim-lang/Nim/issues/4186>`_) + - Fixed "Strange code gen for procs returning arrays" + (`#2259 <https://github.com/nim-lang/Nim/issues/2259>`_) + - Fixed "asynchttpserver may consume unbounded memory reading headers" + (`#3847 <https://github.com/nim-lang/Nim/issues/3847>`_) + + - Fixed "download page still implies master is default branch" + (`#4022 <https://github.com/nim-lang/Nim/issues/4022>`_) + - Fixed "Use standard compiler flags in build script" + (`#2128 <https://github.com/nim-lang/Nim/issues/2128>`_) + - Fixed "CentOS 6 (gcc-4.4.7) compilation failed (redefinition of typedef)" + (`#4272 <https://github.com/nim-lang/Nim/issues/4272>`_) + - Fixed "doc2 has issues with httpclient" + (`#4278 <https://github.com/nim-lang/Nim/issues/4278>`_) + - Fixed "tuples/tuple_with_nil fails without unsigned module" + (`#3579 <https://github.com/nim-lang/Nim/issues/3579>`_) |