diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-04-11 23:26:11 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-04-11 23:26:20 +0200 |
commit | 4c5351a1ebe9de31cc6329059a58e137ee7dae4f (patch) | |
tree | 0e26218cacb2ded33926fa6767f2968a894bcc66 | |
parent | 5e1e1a91455018a3ca5f732bb768550fd9381221 (diff) | |
download | Nim-4c5351a1ebe9de31cc6329059a58e137ee7dae4f.tar.gz |
fixes #6895
-rw-r--r-- | compiler/ast.nim | 4 | ||||
-rw-r--r-- | compiler/semtypes.nim | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index 8fbce84f0..aa7250513 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -1679,9 +1679,9 @@ proc isImportedException*(t: PType): bool = assert(t != nil) if optNoCppExceptions in gGlobalOptions: return false - + let base = t.skipTypes({tyAlias, tyPtr, tyDistinct, tyGenericInst}) - + if base.sym != nil and sfCompileToCpp in base.sym.flags: result = true diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 28d08bb44..a23ee01e1 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -184,6 +184,10 @@ proc semRangeAux(c: PContext, n: PNode, prev: PType): PType = checkSonsLen(n, 3) result = newOrPrevType(tyRange, prev, c) result.n = newNodeI(nkRange, n.info) + # always create a 'valid' range type, but overwrite it later + # because 'semExprWithType' can raise an exception. See bug #6895. + addSonSkipIntLit(result, errorType(c)) + if (n[1].kind == nkEmpty) or (n[2].kind == nkEmpty): localError(n.info, errRangeIsEmpty) @@ -216,7 +220,7 @@ proc semRangeAux(c: PContext, n: PNode, prev: PType): PType = if weakLeValue(result.n[0], result.n[1]) == impNo: localError(n.info, errRangeIsEmpty) - addSonSkipIntLit(result, rangeT[0]) + result[0] = rangeT[0] proc semRange(c: PContext, n: PNode, prev: PType): PType = result = nil |