Merge branch 'issue-6805' of https://github.com/Veladus/Nim into Veladus-issue-6805
This commit is contained in:
commit
d68be11fea
3 changed files with 13 additions and 2 deletions
|
|
@ -639,7 +639,8 @@ type
|
||||||
mEqIdent, mEqNimrodNode, mSameNodeType, mGetImpl,
|
mEqIdent, mEqNimrodNode, mSameNodeType, mGetImpl,
|
||||||
mNHint, mNWarning, mNError,
|
mNHint, mNWarning, mNError,
|
||||||
mInstantiationInfo, mGetTypeInfo, mNGenSym,
|
mInstantiationInfo, mGetTypeInfo, mNGenSym,
|
||||||
mNimvm, mIntDefine, mStrDefine, mRunnableExamples
|
mNimvm, mIntDefine, mStrDefine, mRunnableExamples,
|
||||||
|
mException
|
||||||
|
|
||||||
# things that we can evaluate safely at compile time, even if not asked for it:
|
# things that we can evaluate safely at compile time, even if not asked for it:
|
||||||
const
|
const
|
||||||
|
|
|
||||||
|
|
@ -729,6 +729,16 @@ proc semRaise(c: PContext, n: PNode): PNode =
|
||||||
var typ = n.sons[0].typ
|
var typ = n.sons[0].typ
|
||||||
if typ.kind != tyRef or typ.lastSon.kind != tyObject:
|
if typ.kind != tyRef or typ.lastSon.kind != tyObject:
|
||||||
localError(n.info, errExprCannotBeRaised)
|
localError(n.info, errExprCannotBeRaised)
|
||||||
|
|
||||||
|
# check if the given object inherits from Exception
|
||||||
|
var base = typ.lastSon
|
||||||
|
while true:
|
||||||
|
if base.sym.magic == mException:
|
||||||
|
break
|
||||||
|
if base.lastSon == nil:
|
||||||
|
localError(n.info, "raised object of type $1 does not inherit from Exception", [typ.sym.name.s])
|
||||||
|
return
|
||||||
|
base = base.lastSon
|
||||||
|
|
||||||
proc addGenericParamListToScope(c: PContext, n: PNode) =
|
proc addGenericParamListToScope(c: PContext, n: PNode) =
|
||||||
if n.kind != nkGenericParams: illFormedAst(n)
|
if n.kind != nkGenericParams: illFormedAst(n)
|
||||||
|
|
|
||||||
|
|
@ -463,7 +463,7 @@ type
|
||||||
line*: int ## line number of the proc that is currently executing
|
line*: int ## line number of the proc that is currently executing
|
||||||
filename*: cstring ## filename of the proc that is currently executing
|
filename*: cstring ## filename of the proc that is currently executing
|
||||||
|
|
||||||
Exception* {.compilerproc.} = object of RootObj ## \
|
Exception* {.compilerproc, magic: "Exception".} = object of RootObj ## \
|
||||||
## Base exception class.
|
## Base exception class.
|
||||||
##
|
##
|
||||||
## Each exception has to inherit from `Exception`. See the full `exception
|
## Each exception has to inherit from `Exception`. See the full `exception
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue