summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2018-11-30 08:12:11 +0100
committerAndreas Rumpf <rumpf_a@web.de>2018-11-30 08:12:11 +0100
commit2f13d277201ca8f30c820ba4235223e3f11daa36 (patch)
tree9f887da539f85bbdcebb4608824371cd9690a88e
parent350396e1cab824ec69a9a06380ff15a7fa799819 (diff)
downloadNim-2f13d277201ca8f30c820ba4235223e3f11daa36.tar.gz
improve line info retreival (#9822)
* improve line info
* fix error message
-rw-r--r--compiler/semexprs.nim9
-rw-r--r--tests/errmsgs/tshow_asgn.nim2
2 files changed, 9 insertions, 2 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 669862c56..68dd99f3e 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -1490,6 +1490,13 @@ proc asgnToResultVar(c: PContext, n, le, ri: PNode) {.inline.} =
 template resultTypeIsInferrable(typ: PType): untyped =
   typ.isMetaType and typ.kind != tyTypeDesc
 
+
+proc goodLineInfo(arg: PNode): TLineinfo =
+  if arg.kind == nkStmtListExpr and arg.len > 0:
+    goodLineInfo(arg[^1])
+  else:
+    arg.info
+
 proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
   checkSonsLen(n, 2, c.config)
   var a = n.sons[0]
@@ -1571,7 +1578,7 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
         else:
           typeMismatch(c.config, n.info, lhs.typ, rhsTyp)
 
-    n.sons[1] = fitNode(c, le, rhs, n.info)
+    n.sons[1] = fitNode(c, le, rhs, goodLineInfo(n[1]))
     liftTypeBoundOps(c, lhs.typ, lhs.info)
     #liftTypeBoundOps(c, n.sons[0].typ, n.sons[0].info)
 
diff --git a/tests/errmsgs/tshow_asgn.nim b/tests/errmsgs/tshow_asgn.nim
index 1627c9b71..28a9acbeb 100644
--- a/tests/errmsgs/tshow_asgn.nim
+++ b/tests/errmsgs/tshow_asgn.nim
@@ -1,7 +1,7 @@
 discard """
   errormsg: "type mismatch: got <int> but expected 'cshort = int16'"
   line: 12
-  column: 10
+  column: 27
   file: "tshow_asgn.nim"
 """