diff options
author | Dominik Picheta <dominikpicheta@gmail.com> | 2017-02-01 21:51:17 +0100 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@gmail.com> | 2017-02-01 21:51:17 +0100 |
commit | 814f527175c0141c8f023b100461e72a9e990e6c (patch) | |
tree | 88d59ab55b66ee3b1b5c1916c024bc9ef012d3c6 | |
parent | 3cbfd56e1d02f30124a15db6104ac5d7ffbbbea3 (diff) | |
download | Nim-814f527175c0141c8f023b100461e72a9e990e6c.tar.gz |
Fixes based on @Araq's feedback.
-rw-r--r-- | compiler/ast.nim | 2 | ||||
-rw-r--r-- | compiler/semstmts.nim | 3 | ||||
-rw-r--r-- | compiler/transf.nim | 4 |
3 files changed, 5 insertions, 4 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index 155113d8a..4ea68dc99 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -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 = diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index f428b4708..35c686bcb 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -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] diff --git a/compiler/transf.nim b/compiler/transf.nim index 3a4e25eb5..8944ff43b 100644 --- a/compiler/transf.nim +++ b/compiler/transf.nim @@ -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())` |