Fixes based on @Araq's feedback.

This commit is contained in:
Dominik Picheta
2017-02-01 21:51:17 +01:00
parent 3cbfd56e1d
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.
result = typ
if result.kind == tyRef:
result = result.sons[0]
result = result.lastSon
when false:
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 symbolNode: PNode = nil # e.g. `foobar`
# 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]
symbolNode = a.sons[j].sons[2]

View File

@@ -21,7 +21,7 @@
import
intsets, strutils, lists, options, ast, astalgo, trees, treetab, msgs, os,
idents, renderer, types, passes, semfold, magicsys, cgmeth, rodread,
lambdalifting, sempass2, lowerings
lambdalifting, sempass2, lowerings, lookups
# implementation
@@ -703,7 +703,7 @@ proc transformCall(c: PTransf, n: PNode): PTransNode =
proc transformExceptBranch(c: PTransf, n: PNode): PTransNode =
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 actions = newTransNode(nkStmtList, n[1].info, 2)
# Generating `let exc = (excType)(getCurrentException())`