Fixes
This commit is contained in:
parent
7302a8ce7a
commit
a274d77b55
2 changed files with 4 additions and 6 deletions
|
|
@ -1667,8 +1667,7 @@ proc skipStmtList*(n: PNode): PNode =
|
||||||
proc toRef*(typ: PType): PType =
|
proc toRef*(typ: PType): PType =
|
||||||
## If ``typ`` is a tyObject then it is converted into a `ref <typ>` and
|
## If ``typ`` is a tyObject then it is converted into a `ref <typ>` and
|
||||||
## returned. Otherwise ``typ`` is simply returned as-is.
|
## returned. Otherwise ``typ`` is simply returned as-is.
|
||||||
let typ = typ.skipTypes({tyAlias, tyGenericInst})
|
if typ.skipTypes({tyAlias, tyGenericInst}).kind == tyObject:
|
||||||
if typ.kind == tyObject:
|
|
||||||
result = newType(tyRef, typ.owner)
|
result = newType(tyRef, typ.owner)
|
||||||
rawAddSon(result, typ)
|
rawAddSon(result, typ)
|
||||||
|
|
||||||
|
|
@ -1676,9 +1675,9 @@ proc toObject*(typ: PType): PType =
|
||||||
## If ``typ`` is a tyRef then its immediate son is returned (which in many
|
## If ``typ`` is a tyRef then its immediate son is returned (which in many
|
||||||
## cases should be a ``tyObject``).
|
## cases should be a ``tyObject``).
|
||||||
## Otherwise ``typ`` is simply returned as-is.
|
## Otherwise ``typ`` is simply returned as-is.
|
||||||
result = typ.skipTypes({tyAlias, tyGenericInst})
|
let t = typ.skipTypes({tyAlias, tyGenericInst})
|
||||||
if result.kind == tyRef:
|
if t.kind == tyRef: t.lastSon
|
||||||
result = result.lastSon
|
else: typ
|
||||||
|
|
||||||
proc isException*(t: PType): bool =
|
proc isException*(t: PType): bool =
|
||||||
# check if `y` is object type and it inherits from Exception
|
# check if `y` is object type and it inherits from Exception
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
outputsub: "-6"
|
outputsub: "-6"
|
||||||
targets: "c cpp"
|
|
||||||
"""
|
"""
|
||||||
type
|
type
|
||||||
ESomething = object of Exception
|
ESomething = object of Exception
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue