diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-10-30 09:18:47 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-10-30 09:19:02 +0100 |
commit | 6cb8bf8045b72180d66c4e6c26f47435406a0252 (patch) | |
tree | b3cbaba43ad78fa765cbde1b6aeb6e1035a53d97 /compiler/ast.nim | |
parent | 560d87f5fde9a1a9d6331894a7b5c1f9641aebf8 (diff) | |
download | Nim-6cb8bf8045b72180d66c4e6c26f47435406a0252.tar.gz |
fixes bug reported in PR #5637
Diffstat (limited to 'compiler/ast.nim')
-rw-r--r-- | compiler/ast.nim | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index e6d967dde..176c2edca 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -1387,6 +1387,14 @@ proc skipTypes*(t: PType, kinds: TTypeKinds): PType = result = t while result.kind in kinds: result = lastSon(result) +proc skipTypes*(t: PType, kinds: TTypeKinds; maxIters: int): PType = + result = t + var i = maxIters + while result.kind in kinds: + result = lastSon(result) + dec i + if i == 0: return nil + proc skipTypesOrNil*(t: PType, kinds: TTypeKinds): PType = ## same as skipTypes but handles 'nil' result = t |