summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2014-08-09 22:55:18 +0200
committerAndreas Rumpf <rumpf_a@web.de>2014-08-09 22:55:18 +0200
commit0f15ebf8cad19d4f0c1953c789ff46bcb7306085 (patch)
tree78be5ef2b840183e6f9ad061d5c650c91c887c29
parent7358fc256f3cf4eec1b73e8c7d257e3d377772f7 (diff)
parentf8ea5f1a37de1d86e494477a8ac95165a3c81310 (diff)
downloadNim-0f15ebf8cad19d4f0c1953c789ff46bcb7306085.tar.gz
Merge pull request #1468 from Varriount/fix-1435
Fix 1435
-rw-r--r--compiler/ast.nim4
-rw-r--r--compiler/ccgtypes.nim1
-rw-r--r--compiler/semexprs.nim2
3 files changed, 7 insertions, 0 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 51319127c..7ad294695 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -1313,6 +1313,10 @@ proc newSons(father: PNode, length: int) =
     setLen(father.sons, length)
 
 proc skipTypes*(t: PType, kinds: TTypeKinds): PType =
+  ## Used throughout the compiler code to test whether a type tree contains or
+  ## doesn't contain a specific type/types - it is often the case that only the
+  ## last child nodes of a type tree need to be searched. This is a really hot
+  ## path within the compiler!
   result = t
   while result.kind in kinds: result = lastSon(result)
 
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index 4c71c6ff7..86142995c 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -122,6 +122,7 @@ proc mapSetType(typ: PType): TCTypeKind =
   else: result = ctArray
 
 proc mapType(typ: PType): TCTypeKind = 
+  ## Maps a nimrod type to a C type
   case typ.kind
   of tyNone, tyStmt: result = ctVoid
   of tyBool: result = ctBool
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index d040675fa..bf13727e5 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -199,6 +199,8 @@ proc isCastable(dst, src: PType): bool =
     result = (dstSize >= srcSize) or
         (skipTypes(dst, abstractInst).kind in IntegralTypes) or
         (skipTypes(src, abstractInst-{tyTypeDesc}).kind in IntegralTypes)
+  if result and src.kind == tyNil:
+    result = dst.size <= platform.ptrSize
   
 proc isSymChoice(n: PNode): bool {.inline.} =
   result = n.kind in nkSymChoices