Implement setLineInfo (#21153)

* Implement setLineInfo

* Add tests
This commit is contained in:
Peter Munch-Ellingsen 2022-12-22 04:34:36 +01:00 • committed by GitHub
commit 613829f7a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 5 deletions

View file

@ -91,7 +91,7 @@ block tlexerex:
block tlineinfo:
block tcopylineinfo:
# issue #5617, feature request
type Test = object
@ -103,6 +103,27 @@ block tlineinfo:
var z = mixer(Test)
doAssert z
block tsetgetlineinfo:
# issue #21098, feature request
type Test = object
macro mixer1(n: typed): untyped =
let x = newIdentNode("echo")
var lineInfo = n.lineInfoObj
x.setLineInfo lineInfo
result = newLit(x.lineInfo == n.lineInfo)
macro mixer2(n: typed): untyped =
let x = newIdentNode("echo")
var lineInfo = n.lineInfoObj
lineInfo.line += 1
x.setLineInfo lineInfo
result = newLit(x.lineInfo != n.lineInfo)
doAssert mixer1(Test)
doAssert mixer2(Test)
block tdebugstmt: