Fixes 7845

This commit is contained in:
cooldome 2018-06-10 22:49:09 +01:00
commit 7302a8ce7a
3 changed files with 24 additions and 9 deletions

View file

@ -755,9 +755,10 @@ proc semRaise(c: PContext, n: PNode): PNode =
checkSonsLen(n, 1, c.config)
if n[0].kind != nkEmpty:
n[0] = semExprWithType(c, n[0])
let typ = n[0].typ
var typ = n[0].typ
if not isImportedException(typ, c.config):
if typ.kind != tyRef or typ.lastSon.kind != tyObject:
typ = typ.skipTypes({tyAlias, tyGenericInst})
if typ.kind != tyRef:
localError(c.config, n.info, errExprCannotBeRaised)
if not isException(typ.lastSon):
localError(c.config, n.info, "raised object of type $1 does not inherit from Exception",