summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-01-29 02:13:53 +0100
committerAraq <rumpf_a@web.de>2012-01-29 02:13:53 +0100
commit23340695d03eb6150a4a9068681795232e4f0734 (patch)
tree51626aff70ebee5a5cbec5141e81eb700d15174a
parent1a2ccd6a23e1fbc4523b814ce4b444c721c6d57f (diff)
downloadNim-23340695d03eb6150a4a9068681795232e4f0734.tar.gz
fixes #89
-rw-r--r--compiler/ccgcalls.nim5
-rwxr-xr-xlib/system/debugger.nim10
-rw-r--r--tests/compile/tsortcall.nim5
3 files changed, 16 insertions, 4 deletions
diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim
index 23dd05b50..b468c4dee 100644
--- a/compiler/ccgcalls.nim
+++ b/compiler/ccgcalls.nim
@@ -83,7 +83,10 @@ proc openArrayLoc(p: BProc, n: PNode): PRope =
   of tyOpenArray:
     result = ropef("$1, $1Len0", [rdLoc(a)])
   of tyString, tySequence:
-    result = ropef("$1->data, $1->$2", [a.rdLoc, lenField()])
+    if skipTypes(n.typ, abstractInst).kind == tyVar:
+      result = ropef("(*$1)->data, (*$1)->$2", [a.rdLoc, lenField()])
+    else:
+      result = ropef("$1->data, $1->$2", [a.rdLoc, lenField()])
   of tyArray, tyArrayConstr:
     result = ropef("$1, $2", [rdLoc(a), toRope(lengthOrd(a.t))])
   else: InternalError("openArrayLoc: " & typeToString(a.t))
diff --git a/lib/system/debugger.nim b/lib/system/debugger.nim
index 49a2da89f..6d5e2d648 100755
--- a/lib/system/debugger.nim
+++ b/lib/system/debugger.nim
@@ -603,8 +603,11 @@ proc genericHashAux(dest: Pointer, mt: PNimType, shallow: bool,
     result = h
     if x != nil:
       let s = cast[NimString](x)
-      let y = cast[pointer](cast[int](x) -% 2*sizeof(int))
-      result = result !& hash(x, s.len + 2*sizeof(int))
+      when true:
+        result = result !& hash(x, s.len)
+      else:
+        let y = cast[pointer](cast[int](x) -% 2*sizeof(int))
+        result = result !& hash(y, s.len + 2*sizeof(int))
   of tySequence:
     var x = cast[ppointer](dest)
     var dst = cast[taddress](cast[ppointer](dest)[])
@@ -627,8 +630,9 @@ proc genericHashAux(dest: Pointer, mt: PNimType, shallow: bool,
     if shallow:
       result = h !& hash(dest, mt.size)
     else:
+      result = h
       var s = cast[ppointer](dest)[]
-      if s != nil: result = genericHashAux(s, mt.base, shallow, h)
+      if s != nil: result = genericHashAux(s, mt.base, shallow, result)
   else:
     result = h !& hash(dest, mt.size) # hash raw bits
 
diff --git a/tests/compile/tsortcall.nim b/tests/compile/tsortcall.nim
new file mode 100644
index 000000000..efe1d0b8b
--- /dev/null
+++ b/tests/compile/tsortcall.nim
@@ -0,0 +1,5 @@
+import algorithm
+
+proc foosort(ships: var seq[int]) = sort(ships, system.cmp[int])
+
+