Fixes based on @Araq's feedback.

This commit is contained in:
Dominik Picheta 2017-02-01 21:51:17 +01:00
commit 814f527175
3 changed files with 5 additions and 4 deletions

View file

@ -1598,7 +1598,7 @@ proc toObject*(typ: PType): PType =
## Otherwise ``typ`` is simply returned as-is. ## Otherwise ``typ`` is simply returned as-is.
result = typ result = typ
if result.kind == tyRef: if result.kind == tyRef:
result = result.sons[0] result = result.lastSon
when false: when false:
proc containsNil*(n: PNode): bool = proc containsNil*(n: PNode): bool =

View file

@ -286,7 +286,8 @@ proc semTry(c: PContext, n: PNode): PNode =
var typeNode = a.sons[j] # e.g. `Exception` var typeNode = a.sons[j] # e.g. `Exception`
var symbolNode: PNode = nil # e.g. `foobar` var symbolNode: PNode = nil # e.g. `foobar`
# Handle the case where the `Exception as foobar` syntax is used. # Handle the case where the `Exception as foobar` syntax is used.
if typeNode.kind == nkInfix: if typeNode.kind == nkInfix and
considerQuotedIdent(typeNode[0]).s == "as":
typeNode = a.sons[j].sons[1] typeNode = a.sons[j].sons[1]
symbolNode = a.sons[j].sons[2] symbolNode = a.sons[j].sons[2]

View file

@ -21,7 +21,7 @@
import import
intsets, strutils, lists, options, ast, astalgo, trees, treetab, msgs, os, intsets, strutils, lists, options, ast, astalgo, trees, treetab, msgs, os,
idents, renderer, types, passes, semfold, magicsys, cgmeth, rodread, idents, renderer, types, passes, semfold, magicsys, cgmeth, rodread,
lambdalifting, sempass2, lowerings lambdalifting, sempass2, lowerings, lookups
# implementation # implementation
@ -703,7 +703,7 @@ proc transformCall(c: PTransf, n: PNode): PTransNode =
proc transformExceptBranch(c: PTransf, n: PNode): PTransNode = proc transformExceptBranch(c: PTransf, n: PNode): PTransNode =
result = transformSons(c, n) result = transformSons(c, n)
if n[0].kind == nkInfix: if n[0].kind == nkInfix and considerQuotedIdent(n[0][0]).s == "as":
let excTypeNode = n[0][1] let excTypeNode = n[0][1]
let actions = newTransNode(nkStmtList, n[1].info, 2) let actions = newTransNode(nkStmtList, n[1].info, 2)
# Generating `let exc = (excType)(getCurrentException())` # Generating `let exc = (excType)(getCurrentException())`