diff options
author | metagn <metagngn@gmail.com> | 2023-05-02 12:28:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-02 11:28:52 +0200 |
commit | e5d0907a42112ce28ae2cbd13d095c0d7c23fd91 (patch) | |
tree | eec33c6690fee50dacf1a7421b21df18eb9f86f0 /tests | |
parent | ca82b4ea16eb7d48b6851110bcb4667570a97f52 (diff) | |
download | Nim-e5d0907a42112ce28ae2cbd13d095c0d7c23fd91.tar.gz |
line info for strformat + fix issue with typed templates (#21761)
* line info in strformat * also fix #20381
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stdlib/tstrformat.nim | 10 | ||||
-rw-r--r-- | tests/stdlib/tstrformatlineinfo.nim | 8 |
2 files changed, 18 insertions, 0 deletions
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]# |