From e5d0907a42112ce28ae2cbd13d095c0d7c23fd91 Mon Sep 17 00:00:00 2001 From: metagn Date: Tue, 2 May 2023 12:28:52 +0300 Subject: line info for strformat + fix issue with typed templates (#21761) * line info in strformat * also fix #20381 --- tests/stdlib/tstrformat.nim | 10 ++++++++++ tests/stdlib/tstrformatlineinfo.nim | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/stdlib/tstrformatlineinfo.nim (limited to 'tests/stdlib') diff --git a/tests/stdlib/tstrformat.nim b/tests/stdlib/tstrformat.nim index 0b163125b..3c0d55c1d 100644 --- a/tests/stdlib/tstrformat.nim +++ b/tests/stdlib/tstrformat.nim @@ -562,6 +562,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"] static: main() main() diff --git a/tests/stdlib/tstrformatlineinfo.nim b/tests/stdlib/tstrformatlineinfo.nim new file mode 100644 index 000000000..3a7bf0d33 --- /dev/null +++ b/tests/stdlib/tstrformatlineinfo.nim @@ -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]# -- cgit 1.4.1-2-gfad0