summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xcompiler/semtypes.nim9
-rwxr-xr-xlib/pure/sockets.nim2
-rwxr-xr-xlib/wrappers/openssl.nim2
-rw-r--r--tests/reject/tnotnil.nim12
-rwxr-xr-xtodo.txt3
5 files changed, 23 insertions, 5 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index 9efeba5b7..6478c1ec6 100755
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -787,6 +787,12 @@ proc semTypeExpr(c: PContext, n: PNode): PType =
   else:
     LocalError(n.info, errTypeExpected, n.renderTree)
 
+proc freshType(res, prev: PType): PType {.inline.} =
+  if prev.isNil:
+    result = copyType(result, result.owner, keepId=false)
+  else:
+    result = res
+
 proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
   result = nil
   if gCmd == cmdIdeTools: suggestExpr(c, n)
@@ -825,7 +831,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
         checkSonsLen(n, 3)
         result = semTypeNode(c, n.sons[1], prev)
         if result.kind in NilableTypes and n.sons[2].kind == nkNilLit:
-          # XXX this is wrong for tyString at least
+          result = freshType(result, prev)
           result.flags.incl(tfNotNil)
         else:
           LocalError(n.info, errGenerated, "invalid type")
@@ -920,6 +926,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
   of nkSharedTy:
     checkSonsLen(n, 1)
     result = semTypeNode(c, n.sons[0], prev)
+    result = freshType(result, prev)
     result.flags.incl(tfShared)
   else:
     LocalError(n.info, errTypeExpected)
diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim
index 371641b06..6a3c644bd 100755
--- a/lib/pure/sockets.nim
+++ b/lib/pure/sockets.nim
@@ -14,6 +14,8 @@
 ## For OpenSSL support compile with ``-d:ssl``. When using SSL be aware that
 ## most functions will then raise ``ESSL`` on SSL errors.
 
+{.deadCodeElim: on.}
+
 when hostos == "solaris":
   {.passl: "-lsocket -lnsl".}
 
diff --git a/lib/wrappers/openssl.nim b/lib/wrappers/openssl.nim
index 1063f401d..752e594d1 100755
--- a/lib/wrappers/openssl.nim
+++ b/lib/wrappers/openssl.nim
@@ -39,6 +39,8 @@
 
 ## OpenSSL support
 
+{.deadCodeElim: on.}
+
 when defined(WINDOWS): 
   const 
     DLLSSLName = "(ssleay32|libssl32).dll"
diff --git a/tests/reject/tnotnil.nim b/tests/reject/tnotnil.nim
index 8676aedf8..b02e33713 100644
--- a/tests/reject/tnotnil.nim
+++ b/tests/reject/tnotnil.nim
@@ -1,5 +1,5 @@
 discard """
-  line: 11
+  line: 22
   errormgs: "type mismatch"
 """
 
@@ -7,9 +7,17 @@ type
   PObj = ref TObj not nil
   TObj = object
     x: int
+  
+  MyString = string not nil
 
-var x: PObj = nil
+#var x: PObj = nil
 
 proc p(x: string not nil): int =
   result = 45
 
+proc q(x: MyString) = nil
+proc q2(x: string) = nil
+
+q2(nil)
+q(nil)
+
diff --git a/todo.txt b/todo.txt
index ca2def6aa..f736ce8dd 100755
--- a/todo.txt
+++ b/todo.txt
@@ -1,7 +1,6 @@
 version 0.9.2
 =============
 
-- fix tfShared and tfNotNil
 - test&finish first class iterators:
   * nested iterators
   * test generic iterators
@@ -20,7 +19,7 @@ version 0.9.X
 =============
 
 - implement the missing features wrt inheritance
-- implement generic methods
+- implement generic methods and generic converters
 - improve the compiler as a service
 - ``=`` should be overloadable; requires specialization for ``=``
 - implement constructors + full 'not nil' checking