From 81f15184e51acaeb05348c8f6db921f380150554 Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 19 Jun 2019 09:48:21 +0200 Subject: [PATCH] fixes #11436 (cherry picked from commit 296c48de5e502f61f8f969c64a8c364bfe1ee0bc) --- compiler/guards.nim | 7 ++++--- compiler/msgs.nim | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/guards.nim b/compiler/guards.nim index bfa295fd21..0a1c5640dd 100644 --- a/compiler/guards.nim +++ b/compiler/guards.nim @@ -981,9 +981,10 @@ proc buildElse(n: PNode; o: Operators): PNode = var s = newNodeIT(nkCurly, n.info, settype(n.sons[0])) for i in 1..n.len-2: let branch = n.sons[i] - assert branch.kind == nkOfBranch - for j in 0..branch.len-2: - s.add(branch.sons[j]) + assert branch.kind != nkElse + if branch.kind == nkOfBranch: + for j in 0..branch.len-2: + s.add(branch.sons[j]) result = newNodeI(nkCall, n.info, 3) result.sons[0] = newSymNode(o.opContains) result.sons[1] = s diff --git a/compiler/msgs.nim b/compiler/msgs.nim index bbee27e67d..2162ee559c 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -452,7 +452,8 @@ proc sourceLine*(conf: ConfigRef; i: TLineInfo): string = proc writeSurroundingSrc(conf: ConfigRef; info: TLineInfo) = const indent = " " msgWriteln(conf, indent & $sourceLine(conf, info)) - msgWriteln(conf, indent & spaces(info.col) & '^') + if info.col >= 0: + msgWriteln(conf, indent & spaces(info.col) & '^') proc formatMsg*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string): string = let title = case msg