mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
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:
@@ -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()
|
||||
|
||||
8
tests/stdlib/tstrformatlineinfo.nim
Normal file
8
tests/stdlib/tstrformatlineinfo.nim
Normal 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]#
|
||||
Reference in New Issue
Block a user