From 1b41c3122be1fa2628d814893a4f3a1196b762fc Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Mon, 29 Jun 2020 00:34:05 -0700 Subject: [PATCH] fix #13432 typetraits.$: $(int,) is now (int,); $tuple[] is now tuple[] (#14799) * typetraits.$: $(int,) is now (int,); $tuple[] is now tuple[] * changelog --- changelog.md | 1 + compiler/types.nim | 3 ++- lib/pure/typetraits.nim | 21 --------------------- tests/metatype/ttypetraits.nim | 31 +++++++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/changelog.md b/changelog.md index 54996ea34..d5f3c8aa9 100644 --- a/changelog.md +++ b/changelog.md @@ -115,6 +115,7 @@ - `macros.newLit` now preserves named vs unnamed tuples; use `-d:nimHasWorkaround14720` to keep old behavior - Add `random.gauss`, that uses the ratio of uniforms method of sampling from a Gaussian distribution. - Add `typetraits.elementType` to get element type of an iterable. +- `typetraits.$`: `$(int,)` is now `"(int,)"`; `$tuple[]` is now `"tuple[]"` ## Language changes - In the newruntime it is now allowed to assign to the discriminator field diff --git a/compiler/types.nim b/compiler/types.nim index b8f58c950..0be0b3eed 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -634,13 +634,14 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string = if i < t.n.len - 1: result.add(", ") result.add(']') elif t.len == 0: - result = "tuple" + result = "tuple[]" else: if prefer == preferTypeName: result = "(" else: result = "tuple of (" for i in 0..