summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/semtypes.nim40
-rw-r--r--lib/core/strs.nim2
-rw-r--r--lib/system/excpt.nim9
3 files changed, 39 insertions, 12 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index c3784f7b6..29ed1b870 100644
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -144,9 +144,7 @@ proc semSet(c: PContext, n: PNode, prev: PType): PType =
     localError(c.config, n.info, errXExpectsOneTypeParam % "set")
     addSonSkipIntLit(result, errorType(c))
 
-proc semContainer(c: PContext, n: PNode, kind: TTypeKind, kindStr: string,
-                  prev: PType): PType =
-  result = newOrPrevType(kind, prev, c)
+proc semContainerArg(c: PContext; n: PNode, kindStr: string; result: PType) =
   if sonsLen(n) == 2:
     var base = semTypeNode(c, n.sons[1], nil)
     if base.kind == tyVoid:
@@ -156,6 +154,11 @@ proc semContainer(c: PContext, n: PNode, kind: TTypeKind, kindStr: string,
     localError(c.config, n.info, errXExpectsOneTypeParam % kindStr)
     addSonSkipIntLit(result, errorType(c))
 
+proc semContainer(c: PContext, n: PNode, kind: TTypeKind, kindStr: string,
+                  prev: PType): PType =
+  result = newOrPrevType(kind, prev, c)
+  semContainerArg(c, n, kindStr, result)
+
 proc semVarargs(c: PContext, n: PNode, prev: PType): PType =
   result = newOrPrevType(tyVarargs, prev, c)
   if sonsLen(n) == 2 or sonsLen(n) == 3:
@@ -1505,9 +1508,29 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
     of mSet: result = semSet(c, n, prev)
     of mOrdinal: result = semOrdinal(c, n, prev)
     of mSeq:
-      result = semContainer(c, n, tySequence, "seq", prev)
+      let s = c.graph.sysTypes[tySequence]
+      assert s != nil
+      assert prev == nil
+      result = copyType(s, s.owner, keepId=false)
+      # XXX figure out why this has children already...
+      result.sons.setLen 0
+      result.n = nil
       if c.config.selectedGc == gcDestructors:
-        incl result.flags, tfHasAsgn
+        result.flags = {tfHasAsgn}
+      else:
+        result.flags = {}
+      semContainerArg(c, n, "seq", result)
+      when false:
+        debugT = true
+        echo "Start!"
+        #debug result
+        assert(not containsGenericType(result))
+        debugT = false
+        echo "End!"
+      when false:
+        result = semContainer(c, n, tySequence, "seq", prev)
+        if c.config.selectedGc == gcDestructors:
+          incl result.flags, tfHasAsgn
     of mOpt: result = semContainer(c, n, tyOpt, "opt", prev)
     of mVarargs: result = semVarargs(c, n, prev)
     of mTypeDesc, mTypeTy:
@@ -1681,8 +1704,9 @@ proc processMagicType(c: PContext, m: PSym) =
   of mString:
     setMagicType(c.config, m, tyString, c.config.target.ptrSize)
     rawAddSon(m.typ, getSysType(c.graph, m.info, tyChar))
-    if c.config.selectedGc == gcDestructors:
-      incl m.typ.flags, tfHasAsgn
+    when false:
+      if c.config.selectedGc == gcDestructors:
+        incl m.typ.flags, tfHasAsgn
   of mCstring:
     setMagicType(c.config, m, tyCString, c.config.target.ptrSize)
     rawAddSon(m.typ, getSysType(c.graph, m.info, tyChar))
@@ -1724,6 +1748,8 @@ proc processMagicType(c: PContext, m: PSym) =
     setMagicType(c.config, m, tySequence, 0)
     if c.config.selectedGc == gcDestructors:
       incl m.typ.flags, tfHasAsgn
+    assert c.graph.sysTypes[tySequence] == nil
+    c.graph.sysTypes[tySequence] = m.typ
   of mOpt:
     setMagicType(c.config, m, tyOpt, 0)
   of mOrdinal:
diff --git a/lib/core/strs.nim b/lib/core/strs.nim
index 562beaa91..186add52a 100644
--- a/lib/core/strs.nim
+++ b/lib/core/strs.nim
@@ -46,7 +46,7 @@ template frees(s) =
     s.p.region.dealloc(s.p.region, s.p, contentSize(s.p.cap))
 
 proc `=destroy`(s: var string) =
-  var a = cast[ptr NimStringV2[T]](addr s)
+  var a = cast[ptr NimStringV2](addr s)
   frees(a)
   a.len = 0
   a.p = nil
diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim
index dabfe010e..1e590965a 100644
--- a/lib/system/excpt.nim
+++ b/lib/system/excpt.nim
@@ -428,10 +428,11 @@ proc getStackTrace(e: ref Exception): string =
   else:
     result = ""
 
-proc getStackTraceEntries*(e: ref Exception): seq[StackTraceEntry] =
-  ## Returns the attached stack trace to the exception ``e`` as
-  ## a ``seq``. This is not yet available for the JS backend.
-  shallowCopy(result, e.trace)
+when not defined(gcDestructors):
+  proc getStackTraceEntries*(e: ref Exception): seq[StackTraceEntry] =
+    ## Returns the attached stack trace to the exception ``e`` as
+    ## a ``seq``. This is not yet available for the JS backend.
+    shallowCopy(result, e.trace)
 
 when defined(nimRequiresNimFrame):
   proc stackOverflow() {.noinline.} =