From 3e0fac7c20c624ba69ecff615af6bc6a78dcaeec Mon Sep 17 00:00:00 2001 From: Miran Date: Wed, 22 May 2019 18:57:52 +0200 Subject: [PATCH] finish #11292: fix `addQuoted` and add changelog entry (#11301) * finish #11292: fix `addQuoted` and add changelog entry * JS is special --- changelog.md | 12 ++++++++++-- lib/system.nim | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index afb21f9f1e..cb87e960e9 100644 --- a/changelog.md +++ b/changelog.md @@ -34,7 +34,9 @@ - To use multi-methods, explicit `--multimethods:on` is now needed. -- Compile time checks for integer and float conversions are now stricter. For example, `const x = uint32(-1)` now gives a compile time error instead of being equivalent to `const x = 0xFFFFFFFF'u32`. +- Compile time checks for integer and float conversions are now stricter. + For example, `const x = uint32(-1)` now gives a compile time error instead + of being equivalent to `const x = 0xFFFFFFFF'u32`. - Using `typed` as the result type in templates/macros now means "expression with a type". The old meaning of `typed` is preserved @@ -43,6 +45,7 @@ - A bug allowed `macro foo(): int = 123` to compile even though a macros has to return a `NimNode`. This has been fixed. + #### Breaking changes in the standard library - `osproc.execProcess` now also takes a `workingDir` parameter. @@ -105,6 +108,10 @@ - Custom types that should be supported by `strformat` (&) now need an explicit overload of `formatValue`. +- procs `string.add(int)` and `string.add(float)` which implicitly convert + ints and floats to string have been deprecated. + Use `string.addInt(int)` and `string.addFloat(float)` instead. + #### Breaking changes in the compiler @@ -201,7 +208,8 @@ proc enumToString*(enums: openArray[enum]): string = - The switch ``-d:useWinAnsi`` is not supported anymore. -- In `times` module, procs `format` and `parse` accept a new optional `DateTimeLocale` argument for formatting/parsing dates in other languages. +- In `times` module, procs `format` and `parse` accept a new optional + `DateTimeLocale` argument for formatting/parsing dates in other languages. ### Language additions diff --git a/lib/system.nim b/lib/system.nim index ce6ed4c7fa..421973cce0 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -4202,6 +4202,10 @@ proc addQuoted*[T](s: var string, x: T) = s.addEscapedChar(x) s.add("'") # prevent temporary string allocation + elif T is int and not defined(JS): + s.addInt(x) + elif T is float and not defined(JS): + s.addFloat(x) elif compiles(s.add(x)): s.add(x) else: