mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-18 08:58:39 +00:00
improve line info retreival (#9822)
* improve line info * fix error message
This commit is contained in:
committed by
Andreas Rumpf
parent
350396e1ca
commit
2f13d27720
@@ -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)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
discard """
|
||||
errormsg: "type mismatch: got <int> but expected 'cshort = int16'"
|
||||
line: 12
|
||||
column: 10
|
||||
column: 27
|
||||
file: "tshow_asgn.nim"
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user