summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/ccgtypes.nim16
-rw-r--r--tests/typerel/tnoargopenarray.nim2
-rw-r--r--tests/typerel/typalias.nim2
3 files changed, 11 insertions, 9 deletions
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index c3905f3e6..460cb9297 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -166,6 +166,10 @@ proc getTypeDescAux(m: BModule, typ: PType, check: var IntSet): PRope
 proc needsComplexAssignment(typ: PType): bool = 
   result = containsGarbageCollectedRef(typ)
 
+proc isObjLackingTypeField(typ: PType): bool {.inline.} =
+  result = (typ.kind == tyObject) and ((tfFinal in typ.flags) and
+      (typ.sons[0] == nil) or isPureObject(typ))
+
 proc isInvalidReturnType(rettype: PType): bool = 
   # Arrays and sets cannot be returned by a C procedure, because C is
   # such a poor programming language.
@@ -177,10 +181,12 @@ proc isInvalidReturnType(rettype: PType): bool =
     of ctArray: 
       result = not (skipTypes(rettype, typedescInst).kind in
           {tyVar, tyRef, tyPtr})
-    of ctStruct: 
-      result = needsComplexAssignment(skipTypes(rettype, typedescInst))
+    of ctStruct:
+      let t = skipTypes(rettype, typedescInst)
+      result = needsComplexAssignment(t) or
+          (t.kind == tyObject and not isObjLackingTypeField(t))
     else: result = false
-  
+
 const 
   CallingConvToStr: array[TCallingConvention, string] = ["N_NIMCALL", 
     "N_STDCALL", "N_CDECL", "N_SAFECALL", 
@@ -678,10 +684,6 @@ when false:
     var tmp = getNimType(m)
     appf(m.s[cfsTypeInit2], "$2 = &$1;$n", [tmp, name])
 
-proc isObjLackingTypeField(typ: PType): bool {.inline.} =
-  result = (typ.kind == tyObject) and ((tfFinal in typ.flags) and
-      (typ.sons[0] == nil) or isPureObject(typ))
-
 proc genTypeInfoAuxBase(m: BModule, typ: PType, name, base: PRope) =
   var nimtypeKind: int
   #allocMemTI(m, typ, name)
diff --git a/tests/typerel/tnoargopenarray.nim b/tests/typerel/tnoargopenarray.nim
index 20ebe5ecc..3e65194ff 100644
--- a/tests/typerel/tnoargopenarray.nim
+++ b/tests/typerel/tnoargopenarray.nim
@@ -1,7 +1,7 @@
 
 import db_sqlite
 
-var db: DbConn
+var db: TDbConn
 exec(db, sql"create table blabla()")
 
 
diff --git a/tests/typerel/typalias.nim b/tests/typerel/typalias.nim
index 40ff06765..55dcb9fa6 100644
--- a/tests/typerel/typalias.nim
+++ b/tests/typerel/typalias.nim
@@ -1,7 +1,7 @@
 
 type
   TMyObj = TYourObj
-  TYourObj = object of TObject
+  TYourObj = object of RootObj
     x, y: int
   
 proc init: TYourObj =