summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2018-09-15 14:33:15 -0500
committerGanesh Viswanathan <dev@genotrance.com>2018-09-15 14:33:15 -0500
commite4fa1c81cb555a726fa79133bb20e938e8c68b02 (patch)
tree1185eab4bd2c2e66567c2dba0fe988355595ceb3 /compiler
parentb966945ab219e58023cdf85c77804519c96c231e (diff)
parent0e33a8676e325fa4174893291ed41d59b689c577 (diff)
downloadNim-e4fa1c81cb555a726fa79133bb20e938e8c68b02.tar.gz
Merge remote-tracking branch 'upstream/devel' into test-6434
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgexprs.nim3
-rw-r--r--compiler/ccgtypes.nim15
-rw-r--r--compiler/pathutils.nim2
3 files changed, 11 insertions, 9 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index 56ecf5ba3..a7a28a51c 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -1596,10 +1596,11 @@ proc genSwap(p: BProc, e: PNode, d: var TLoc) =
   genAssignment(p, a, b, {})
   genAssignment(p, b, tmp, {})
 
-proc rdSetElemLoc(conf: ConfigRef; a: TLoc, setType: PType): Rope =
+proc rdSetElemLoc(conf: ConfigRef; a: TLoc, typ: PType): Rope =
   # read a location of an set element; it may need a subtraction operation
   # before the set operation
   result = rdCharLoc(a)
+  let setType = typ.skipTypes(abstractPtrs)
   assert(setType.kind == tySet)
   if firstOrd(conf, setType) != 0:
     result = "($1- $2)" % [result, rope(firstOrd(conf, setType))]
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index dd79f4846..52a4a72f2 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -162,9 +162,9 @@ proc mapType(conf: ConfigRef; typ: PType): TCTypeKind =
     var base = skipTypes(typ.lastSon, typedescInst)
     case base.kind
     of tyOpenArray, tyArray, tyVarargs: result = ctPtrToArray
-    #of tySet:
-    #  if mapSetType(base) == ctArray: result = ctPtrToArray
-    #  else: result = ctPtr
+    of tySet:
+      if mapSetType(conf, base) == ctArray: result = ctPtrToArray
+      else: result = ctPtr
     # XXX for some reason this breaks the pegs module
     else: result = ctPtr
   of tyPointer: result = ctPtr
@@ -641,10 +641,11 @@ proc getTypeDescAux(m: BModule, origTyp: PType, check: var IntSet): Rope =
                     compileToCpp(m): "&" else: "*"
     var et = origTyp.skipTypes(abstractInst).lastSon
     var etB = et.skipTypes(abstractInst)
-    if etB.kind in {tyArray, tyOpenArray, tyVarargs}:
-      # this is correct! sets have no proper base type, so we treat
-      # ``var set[char]`` in `getParamTypeDesc`
-      et = elemType(etB)
+    if mapType(m.config, t) == ctPtrToArray:
+      if etB.kind == tySet:
+        et = getSysType(m.g.graph, unknownLineInfo(), tyUInt8)
+      else:
+        et = elemType(etB)
       etB = et.skipTypes(abstractInst)
       star[0] = '*'
     case etB.kind
diff --git a/compiler/pathutils.nim b/compiler/pathutils.nim
index ef0fa4abd..03fcfe07e 100644
--- a/compiler/pathutils.nim
+++ b/compiler/pathutils.nim
@@ -114,7 +114,7 @@ proc canon(x: string; result: var string; state: var int) =
       if d > 0: setLen(result, d-1)
     elif isDot(x, b):
       discard "discard the dot"
-    elif b[1] > b[0]:
+    elif b[1] >= b[0]:
       if result.len > 0 and result[^1] != DirSep:
         result.add DirSep
       result.add substr(x, b[0], b[1])