improve line info retreival (#9822)

* improve line info
* fix error message
This commit is contained in:
Arne Döring
2018-11-30 08:12:11 +01:00
committed by Andreas Rumpf
parent 350396e1ca
commit 2f13d27720
2 changed files with 9 additions and 2 deletions

View File

@@ -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)

View File

@@ -1,7 +1,7 @@
discard """
errormsg: "type mismatch: got <int> but expected 'cshort = int16'"
line: 12
column: 10
column: 27
file: "tshow_asgn.nim"
"""