line info for strformat + fix issue with typed templates (#21761)

* line info in strformat

* also fix #20381

(cherry picked from commit e5d0907a42)
This commit is contained in:
metagn
2023-05-02 12:28:52 +03:00
committed by narimiran
parent cd0f805832
commit fa3639ba33
3 changed files with 43 additions and 10 deletions

View File

@@ -555,5 +555,16 @@ proc main() =
doAssert &"""{(if true: "'" & "'" & ')' else: "")}""" == "'')"
doAssert &"{(if true: \"\'\" & \"'\" & ')' else: \"\")}" == "'')"
doAssert fmt"""{(if true: "'" & ')' else: "")}""" == "')"
block: # issue #20381
var ss: seq[string]
template myTemplate(s: string) =
ss.add s
ss.add s
proc foo() =
myTemplate fmt"hello"
foo()
doAssert ss == @["hello", "hello"]
# xxx static: main()
main()

View File

@@ -0,0 +1,8 @@
# issue #21759
{.hint[ConvFromXToItselfNotNeeded]: on.}
import std/strformat
echo fmt"{string ""abc""}" #[tt.Hint
^ conversion from string to itself is pointless]#