summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-05-29 08:00:52 +0200
committerAndreas Rumpf <rumpf_a@web.de>2019-05-29 08:00:52 +0200
commit8951680c0547e1b499ac6c3e02bbf3af4876c699 (patch)
tree12bc7851f0cf7891b87726ad5f5c0c4557539c90
parent950f2d7c2f60425155e5f3b902ed067f2e3d2d17 (diff)
downloadNim-8951680c0547e1b499ac6c3e02bbf3af4876c699.tar.gz
fixes #10889
-rw-r--r--compiler/ast.nim14
-rw-r--r--compiler/types.nim11
2 files changed, 11 insertions, 14 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 604e9d728..56c7edb90 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -1753,20 +1753,6 @@ proc toObject*(typ: PType): PType =
   if t.kind == tyRef: t.lastSon
   else: typ
 
-proc isException*(t: PType): bool =
-  # check if `y` is object type and it inherits from Exception
-  assert(t != nil)
-
-  if t.kind notin {tyObject, tyGenericInst}:
-    return false
-
-  var base = t
-  while base != nil and base.kind in {tyRef, tyObject, tyGenericInst}:
-    if base.sym != nil and base.sym.magic == mException:
-      return true
-    base = base.lastSon
-  return false
-
 proc isImportedException*(t: PType; conf: ConfigRef): bool =
   assert t != nil
 
diff --git a/compiler/types.nim b/compiler/types.nim
index 8a9af3134..239ff4ed9 100644
--- a/compiler/types.nim
+++ b/compiler/types.nim
@@ -1559,3 +1559,14 @@ proc isTupleRecursive(t: PType, cycleDetector: var IntSet): bool =
 proc isTupleRecursive*(t: PType): bool =
   var cycleDetector = initIntSet()
   isTupleRecursive(t, cycleDetector)
+
+proc isException*(t: PType): bool =
+  # check if `y` is object type and it inherits from Exception
+  assert(t != nil)
+
+  var t = t.skipTypes(abstractInst)
+  while t.kind == tyObject:
+    if t.sym != nil and t.sym.magic == mException: return true
+    if t.sons[0] == nil: break
+    t = skipTypes(t.sons[0], abstractPtrs)
+  return false