mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 21:40:32 +00:00
fixes #10889
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user