From 15f72d0cf1390971e047f22dabf7a9e5b24fd85b Mon Sep 17 00:00:00 2001 From: Veladus Date: Mon, 11 Dec 2017 21:49:28 +0100 Subject: [PATCH] Now analyzes over magics instead of symbol names; but dosn't compile for me --- compiler/ast.nim | 3 ++- compiler/semstmts.nim | 2 +- lib/system.nim | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/ast.nim b/compiler/ast.nim index 5bf4184c95..5b923acb25 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -639,7 +639,8 @@ type mEqIdent, mEqNimrodNode, mSameNodeType, mGetImpl, mNHint, mNWarning, mNError, 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: const diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index a44b2fafc4..c85de35cd2 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -733,7 +733,7 @@ proc semRaise(c: PContext, n: PNode): PNode = # check if the given object inherits from Exception var base = typ.lastSon while true: - if base.sym.name.s == "Exception": + 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]) diff --git a/lib/system.nim b/lib/system.nim index b9f01c3065..ca17f70f6a 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -463,7 +463,7 @@ type line*: int ## line number 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. ## ## Each exception has to inherit from `Exception`. See the full `exception