summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-10-12 17:42:15 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-10-12 17:42:15 +0200
commita2e4ab2e4e3570cd313e8d5422b276625f87e0d7 (patch)
treeceb4d096b6774bfe7fc5982c64d4eaaa10d56e44 /compiler/semstmts.nim
parentd6c401acfbb738d0e91df18cc89c40dc1b28525c (diff)
downloadNim-a2e4ab2e4e3570cd313e8d5422b276625f87e0d7.tar.gz
simple programs now work with the new destroyer pass
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim21
1 files changed, 11 insertions, 10 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index ccf332d3a..c8eda9d94 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -100,15 +100,16 @@ proc semProc(c: PContext, n: PNode): PNode
 include semdestruct
 
 proc semDestructorCheck(c: PContext, n: PNode, flags: TExprFlags) {.inline.} =
-  if efAllowDestructor notin flags and
-      n.kind in nkCallKinds+{nkObjConstr,nkBracket}:
-    if instantiateDestructor(c, n.typ) != nil:
-      localError(n.info, warnDestructor)
-  # This still breaks too many things:
-  when false:
-    if efDetermineType notin flags and n.typ.kind == tyTypeDesc and
-        c.p.owner.kind notin {skTemplate, skMacro}:
-      localError(n.info, errGenerated, "value expected, but got a type")
+  when not newDestructors:
+    if efAllowDestructor notin flags and
+        n.kind in nkCallKinds+{nkObjConstr,nkBracket}:
+      if instantiateDestructor(c, n.typ) != nil:
+        localError(n.info, warnDestructor)
+    # This still breaks too many things:
+    when false:
+      if efDetermineType notin flags and n.typ.kind == tyTypeDesc and
+          c.p.owner.kind notin {skTemplate, skMacro}:
+        localError(n.info, errGenerated, "value expected, but got a type")
 
 proc semExprBranch(c: PContext, n: PNode): PNode =
   result = semExpr(c, n)
@@ -116,7 +117,7 @@ proc semExprBranch(c: PContext, n: PNode): PNode =
     # XXX tyGenericInst here?
     semProcvarCheck(c, result)
     if result.typ.kind == tyVar: result = newDeref(result)
-    when not newDestructors: semDestructorCheck(c, result, {})
+    semDestructorCheck(c, result, {})
 
 proc semExprBranchScope(c: PContext, n: PNode): PNode =
   openScope(c)