genTryCpp to catch by Nim type, ready for first review (#7196)

* Rewrite genTryCpp

* correction

* Implement polymorphic raise in cpp

* revert backticks in emit

* Cleanp a comment

* revert test changes

* better handling of <new> header
This commit is contained in:
cooldome 2018-02-12 20:23:34 +00:00 • committed by Andreas Rumpf
commit d24b6667c6
10 changed files with 110 additions and 79 deletions

View file

@ -737,16 +737,10 @@ proc semRaise(c: PContext, n: PNode): PNode =
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",
[typeToString(typ)])
return
base = base.lastSon
if not typ.lastSon.isException():
localError(n.info, "raised object of type $1 does not inherit from Exception",
[typeToString(typ)])
proc addGenericParamListToScope(c: PContext, n: PNode) =
if n.kind != nkGenericParams: illFormedAst(n)