summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-03-01 23:25:46 +0100
committerAndreas Rumpf <rumpf_a@web.de>2016-03-01 23:25:46 +0100
commit06d4131ce1bb236f0d5a14efdfb12e825c5fee0f (patch)
treeec8c37cc5eed45f2bc07e7ffaf9db3c7c26cab57
parent312281c7cc19bf467207af93a13e9acdd9b34c60 (diff)
downloadNim-06d4131ce1bb236f0d5a14efdfb12e825c5fee0f.tar.gz
fixes #3669
-rw-r--r--compiler/semtypinst.nim16
-rw-r--r--lib/phpcl.nim50
-rw-r--r--tests/generics/t2tables.nim13
3 files changed, 21 insertions, 58 deletions
diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim
index d20704a2a..7ff33f918 100644
--- a/compiler/semtypinst.nim
+++ b/compiler/semtypinst.nim
@@ -203,14 +203,14 @@ proc replaceTypeVarsS(cl: var TReplTypeVars, s: PSym): PSym =
   # symbol is not our business:
   if cl.owner != nil and s.owner != cl.owner:
     return s
-  result = PSym(idTableGet(cl.symMap, s))
-  if result == nil:
-    result = copySym(s, false)
-    incl(result.flags, sfFromGeneric)
-    idTablePut(cl.symMap, s, result)
-    result.owner = s.owner
-    result.typ = replaceTypeVarsT(cl, s.typ)
-    result.ast = replaceTypeVarsN(cl, s.ast)
+  #result = PSym(idTableGet(cl.symMap, s))
+  #if result == nil:
+  result = copySym(s, false)
+  incl(result.flags, sfFromGeneric)
+  #idTablePut(cl.symMap, s, result)
+  result.owner = s.owner
+  result.typ = replaceTypeVarsT(cl, s.typ)
+  result.ast = replaceTypeVarsN(cl, s.ast)
 
 proc lookupTypeVar(cl: var TReplTypeVars, t: PType): PType =
   result = PType(idTableGet(cl.typeMap, t))
diff --git a/lib/phpcl.nim b/lib/phpcl.nim
deleted file mode 100644
index 5eaa00f80..000000000
--- a/lib/phpcl.nim
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-#
-#            Nim's Runtime Library
-#        (c) Copyright 2015 Andreas Rumpf
-#
-#    See the file "copying.txt", included in this
-#    distribution, for details about the copyright.
-#
-
-## PHP compatibility layer.
-
-type
-  PhpArray*[Key, Val] = ref object
-
-  PhpObj* = ref object ## can be a string, an int etc.
-
-proc explode*(sep, x: string): seq[string] {.importc: "explode".}
-template split*(x, sep: string): seq[string] = explode(sep, x)
-
-proc `$`*(x: PhpObj): string {.importcpp: "(#)".}
-proc `++`*(x: PhpObj) {.importcpp: "++(#)".}
-
-proc `==`*(x, y: PhpObj): string {.importcpp: "((#) == (#))".}
-proc `<=`*(x, y: PhpObj): string {.importcpp: "((#) <= (#))".}
-proc `<`*(x, y: PhpObj): string {.importcpp: "((#) < (#))".}
-
-proc toUpper*(x: string): string {.importc: "strtoupper".}
-proc toLower*(x: string): string {.importc: "strtolower".}
-
-proc strtr*(s: string, replacePairs: PhpArray[string, string]): string {.importc.}
-proc strtr*(s, fromm, to: string): string {.importc.}
-
-proc toArray*[K,V](pairs: openarray[(K,V)]): PhpArray[K,V] {.magic:
-  "Array".}
-template strtr*(s: string, replacePairs: openarray[(string, string)]): string =
-  strtr(toArray(replacePairs))
-
-iterator pairs*[K,V](d: PhpArray[K,V]): (K,V) =
-  var k: K
-  var v: V
-  {.emit: "foreach (`d` as `k`=>`v`) {".}
-  yield (k, v)
-  {.emit: "}".}
-
-proc `[]`*[K,V](d: PhpArray[K,V]; k: K): V {.importcpp: "#[#]".}
-proc `[]=`*[K,V](d: PhpArray[K,V]; k: K; v: V) {.importcpp: "#[#] = #".}
-
-proc ksort*[K,V](d: PhpArray[K,V]) {.importc.}
-proc krsort*[K,V](d: PhpArray[K,V]) {.importc.}
-proc keys*[K,V](d: PhpArray[K,V]): seq[K] {.importc.}
diff --git a/tests/generics/t2tables.nim b/tests/generics/t2tables.nim
new file mode 100644
index 000000000..3ef5e621e
--- /dev/null
+++ b/tests/generics/t2tables.nim
@@ -0,0 +1,13 @@
+
+# bug #3669
+
+import tables
+
+type
+  G[T] = object
+    inodes: Table[int, T]
+    rnodes: Table[T, int]
+
+var g: G[string]
+echo g.rnodes["foo"]
+