Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strutils.addf chokes on: ret.addf "foo $1 bar" % ["$"] #14488

Closed
timotheecour opened this issue May 28, 2020 · 1 comment
Closed

strutils.addf chokes on: ret.addf "foo $1 bar" % ["$"] #14488

timotheecour opened this issue May 28, 2020 · 1 comment

Comments

@timotheecour
Copy link
Member

strutils.addf chokes on: ret.addf "foo $1 bar" % ["$"]

Example

var ret: string
ret.addf "foo $1 bar" % ["$"]

Current Output

/Users/timothee/git_clone/nim/timn/tests/nim/all/t10851.nim(7) t10851
/Users/timothee/git_clone/nim/Nim_devel/lib/pure/strutils.nim(2753) addf
/Users/timothee/git_clone/nim/Nim_devel/lib/pure/strutils.nim(2693) invalidFormatString
Error: unhandled exception: invalid format string [ValueError]

Expected Output

works

Possible Solution

  • TBD

Additional Information

nim e013ebc91a22eeccc9546498994b0c561e438599 1.3.5
@timotheecour
Copy link
Member Author

my bad, % should not be used with addf (unless you want that effect):

when true:
  import strutils
  var ret: string
  # ret.addf "foo $1 bar" % ["$"] # bad
  ret.addf "foo $1 bar", ["$"] # good
  doAssert ret == "foo $ bar"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant