improve line info retreival (#9822)
* improve line info * fix error message
This commit is contained in:
parent
350396e1ca
commit
2f13d27720
2 changed files with 9 additions and 2 deletions
|
|
@ -1490,6 +1490,13 @@ proc asgnToResultVar(c: PContext, n, le, ri: PNode) {.inline.} =
|
||||||
template resultTypeIsInferrable(typ: PType): untyped =
|
template resultTypeIsInferrable(typ: PType): untyped =
|
||||||
typ.isMetaType and typ.kind != tyTypeDesc
|
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 =
|
proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
|
||||||
checkSonsLen(n, 2, c.config)
|
checkSonsLen(n, 2, c.config)
|
||||||
var a = n.sons[0]
|
var a = n.sons[0]
|
||||||
|
|
@ -1571,7 +1578,7 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
|
||||||
else:
|
else:
|
||||||
typeMismatch(c.config, n.info, lhs.typ, rhsTyp)
|
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, lhs.typ, lhs.info)
|
||||||
#liftTypeBoundOps(c, n.sons[0].typ, n.sons[0].info)
|
#liftTypeBoundOps(c, n.sons[0].typ, n.sons[0].info)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "type mismatch: got <int> but expected 'cshort = int16'"
|
errormsg: "type mismatch: got <int> but expected 'cshort = int16'"
|
||||||
line: 12
|
line: 12
|
||||||
column: 10
|
column: 27
|
||||||
file: "tshow_asgn.nim"
|
file: "tshow_asgn.nim"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue