From cde3a4f586f5d22bd7acc8849543821a1830008f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20Nihlg=C3=A5rd?= Date: Tue, 9 Jan 2018 00:18:32 +0100 Subject: [PATCH 1/3] Add additional $ fallback to fmt --- lib/pure/strformat.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pure/strformat.nim b/lib/pure/strformat.nim index e04c80794b..d1dedb625c 100644 --- a/lib/pure/strformat.nim +++ b/lib/pure/strformat.nim @@ -221,8 +221,10 @@ template callFormat(res, arg) {.dirty.} = template callFormatOption(res, arg, option) {.dirty.} = when compiles(format(arg, option, res)): format(arg, option, res) - else: + elif compiles(format(arg, option)): res.add format(arg, option) + else: + format($arg, option, res) macro fmt*(pattern: string{lit}): untyped = ## For a specification of the ``fmt`` macro, see the module level documentation. From 624bd847fb2dfdeca00548947ba248a7b32d2e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20Nihlg=C3=A5rd?= Date: Tue, 9 Jan 2018 00:33:39 +0100 Subject: [PATCH 2/3] Add test case --- tests/stdlib/tstrformat.nim | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/stdlib/tstrformat.nim diff --git a/tests/stdlib/tstrformat.nim b/tests/stdlib/tstrformat.nim new file mode 100644 index 0000000000..4e5c614a78 --- /dev/null +++ b/tests/stdlib/tstrformat.nim @@ -0,0 +1,13 @@ +discard """ + action: "run" +""" + +import strformat + +type Obj = object + +proc `$`(o: Obj): string = "foobar" + +var o: Obj +doAssert fmt"{o}" == "foobar" +doAssert fmt"{o:10}" == "foobar " \ No newline at end of file From a54430ea2dc7d39670e0451a04d3b9f349ae8072 Mon Sep 17 00:00:00 2001 From: sleepyqt Date: Wed, 10 Jan 2018 01:02:09 +0300 Subject: [PATCH 3/3] Fix struct packing for VCC. (#7049) "#pragma pack(1)" sets current alligment without pushing into stack, so "#pragma pack(pop)" causing stack underflow. --- compiler/ccgtypes.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 24d3a0dfb4..8a60143fb7 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -496,7 +496,7 @@ proc genRecordFieldsAux(m: BModule, n: PNode, if hasAttribute in CC[cCompiler].props: add(unionBody, "struct __attribute__((__packed__)){" ) else: - addf(unionBody, "#pragma pack(1)$nstruct{", []) + addf(unionBody, "#pragma pack(push, 1)$nstruct{", []) add(unionBody, a) addf(unionBody, "} $1;$n", [sname]) if tfPacked in rectype.flags and hasAttribute notin CC[cCompiler].props: @@ -551,7 +551,7 @@ proc getRecordDesc(m: BModule, typ: PType, name: Rope, if hasAttribute in CC[cCompiler].props: result = structOrUnion(typ) & " __attribute__((__packed__))" else: - result = "#pragma pack(1)" & tnl & structOrUnion(typ) + result = "#pragma pack(push, 1)" & tnl & structOrUnion(typ) else: result = structOrUnion(typ)