Re: Why does &"""{"total":23}""" compile but &"""{"total:":23}""" not compile?
Quoted closers are indeed another wrinkle. If you want a one pass algo you can just track the index of the last `':'` and use it only after you pass the final unquoted closer having framed the two parts. Still doesn't sound hard to have less brittle framing, but effort worth is always subjective. Nim does use `':'` a lot. Maybe @TKurtBond could do the PR? :-)
Re: Why does &"""{"total":23}""" compile but &"""{"total:":23}""" not compile?
No, because you need to find the `}` first. The correct solution is to anticipate quotes then track escape sequences, and track `(`/`[`/`{` opens and wait for them to close.
Re: Why does &"""{"total":23}""" compile but &"""{"total:":23}""" not compile?
As long as `':'` is not allowed in `fmt` part of `{expr:fmt}`, you can probably just frame the `expr` by doing an `rfind` on ':' instead of a `find` (last rather than first), no?
Re: Why does &"""{"total":23}""" compile but &"""{"total:":23}""" not compile?
The quirk is bad but also: String literals inside string literals are ugly.
Re: Why does &"""{"total":23}""" compile but &"""{"total:":23}""" not compile?
The issue is in strformat, it parses until it hits a colon then it gives what it has to Nim to parse an expression ([relevant lines](https://github.com/nim-lang/Nim/blob/eca8f1d79f712613437918e397f7abb58bc29515/lib/pure/strformat.nim#L553-L559)). So the following also fails: import strformat type Foo = object num: int echo &"""<{Foo(num: 3)}>""" Run You can report bugs with the compiler or standard library on the [GitHub issue tracker](https://github.com/nim-lang/Nim/issues).
Why does &"""{"total":23}""" compile but &"""{"total:":23}""" not compile?
The file import strformat echo &"""<{"total":23}>""" Run compiles fine. The file import strformat echo &"""<{"total:":23}>""" Run does not compile. The only difference is the colon (:) after total in the second file. Aren't they both string constants? The strformat documentation refers to the 'fmt"{expr}"' syntax. Is that a full nim expression, or is more limited? (I didn't see an explanation in in strformat.)